What's a good Windows command line option for deleting all files in a given folder older than (n) days?
Also note there may be many thousands of these files, so forfiles
with a shell to cmd
is not a great idea here.. unless you like spawning thousands of command shells. I consider that a pretty nasty hack, so let's see if we can do better!
Ideally, something built into (or easily installable into) Windows Server 2008.
Best Answer
I looked around a bit more and found a powershell way:
Delete all files more than 8 days old from the specified folder (with preview)
(remove the -whatif to make it happen)