Created
March 27, 2014 14:45
-
-
Save mshock/9809113 to your computer and use it in GitHub Desktop.
recursively retrieve file list and delete files older than 60 days (TODO: add CLI args for age and dirs)
This file contains 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
function cleandir($dir) { | |
$a = Get-ChildItem $dir -filter *.* -recurs | |
foreach($x in $a) | |
{ | |
$y = ((Get-Date) - $x.CreationTime).Days | |
if ($y -gt 60 -and $x.PsISContainer -ne $True) | |
{$x.Delete()} | |
} | |
} | |
cleandir('C:\dir'); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment