Skip to content

Instantly share code, notes, and snippets.

@manchot0
Created July 26, 2021 08:29
Show Gist options
  • Save manchot0/91c959c45750537e7936a50345af2154 to your computer and use it in GitHub Desktop.
Save manchot0/91c959c45750537e7936a50345af2154 to your computer and use it in GitHub Desktop.
powershell archive files on date
#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