Skip to content

Instantly share code, notes, and snippets.

@huguogang
Created March 6, 2014 02:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save huguogang/9381188 to your computer and use it in GitHub Desktop.
Save huguogang/9381188 to your computer and use it in GitHub Desktop.
A Windows PowerShell that deleted old files
$nDays = 30
$path = "C:\temp"
$threshold = (Get-Date).AddDays(-$nDays)
Get-ChildItem -Path $path -Recurse | Where-Object {
-not $_.PSIsContainer -and $_.LastWriteTime -lt $threshold
} | Remove-Item -Force
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment