Created
July 26, 2021 08:29
-
-
Save manchot0/91c959c45750537e7936a50345af2154 to your computer and use it in GitHub Desktop.
powershell archive files on date
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#clean recursively all files older than 180 days in the given path | |
$filterDate = (Get-Date).AddDays(-180).Date | |
Get-ChildItem E:\DIR_PATH -Directory | ForEach-Object { | |
Get-ChildItem $_.FullName -Recurse | Where {$_.lastwriteTime.Date -le $filterDate } | Remove-Item | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment