View Single Post
Old 04-14-2008   #3 (permalink)
ajax76
Guest


 

Re: How to delete "old" directories (recursively)?

Get-ChildItem -Recurse -Path .\* |
where{ ($_.mode -match '^d.*') -and
(([datetime]::Today-$_.CreationTime.Date).Days -gt X) } |
%{ Remove-Item $_ }


It's all one line.
Replace X for real value of days and .\* for real path.