https://github.com/jparkerweb/purge-old-directories
💾 PowerShell Scripts designed to help manage and clean up by purging old directories
https://github.com/jparkerweb/purge-old-directories
cleanups-files directory filemanagement powershell purge
Last synced: about 2 months ago
JSON representation
💾 PowerShell Scripts designed to help manage and clean up by purging old directories
- Host: GitHub
- URL: https://github.com/jparkerweb/purge-old-directories
- Owner: jparkerweb
- Created: 2024-06-25T03:33:58.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2024-07-10T14:54:01.000Z (11 months ago)
- Last Synced: 2025-02-13T06:47:50.619Z (4 months ago)
- Topics: cleanups-files, directory, filemanagement, powershell, purge
- Language: PowerShell
- Homepage:
- Size: 11.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# PowerShell for Purging Old Directories
These two PowerShell scripts were designed to help manage and clean up by purging old directories.
## purge-files-in-folder.ps1
### Description
`purge-files-in-folder.ps1` is a PowerShell script that deletes all files in a specified folder using the `robocopy /purge` command. If the folder is empty after the purge, the script deletes the folder as well.
### Usage
```powershell
.\purge-files-in-folder.ps1 -FolderPath [-Force]
```### Parameters
- `-FolderPath`: The path to the folder you want to purge.
- `-Force`: Optional. Runs the script without requiring user confirmation.### Example
```powershell
.\purge-files-in-folder.ps1 -FolderPath "C:\Example\Path" -Force
```### Notes
- Ensure you have the necessary permissions to delete files and folders.
---
## purge-old-folders.ps1
### Description
`purge-old-folders.ps1` is a PowerShell script that calls `purge-files-in-folder.ps1` for directories older than a specified number of months. It helps in cleaning up old directories within a target path in batches.
### Usage
```powershell
.\purge-old-folders.ps1 -TargetPath -MonthsOld [-Force]
.\purge-old-folders.ps1 -h | --help
```### Parameters
- `-TargetPath`: The path to the parent directory containing directories to purge.
- `-MonthsOld`: The age of directories (in months) to purge.
- `-Force`: Optional. Runs the script without requiring user confirmation.
- `-h` or `--help`: Displays usage instructions.### Example
```powershell
.\purge-old-folders.ps1 -TargetPath "C:\Example\Path" -MonthsOld 6 -Force
```### Interactive Usage
If no parameters are provided, the script will:
1. Open a file browser dialog to select the target directory.
2. Prompt the user to enter the number of months.
3. Confirm the target path and months old parameters unless `-Force` is specified.### Notes
- Ensure you have the necessary permissions to delete files and folders.