There is a folder on the disk (Windows Server 2008 R2) containing about a million files, many have a date of two or three years ago.

I want to delete old files (there is a permission “to consider everything that is older than January 01 of the current year to be useless”), but even just entering the folder is not a quick operation.

Is it possible to somehow delete old files? On the del command itself, I didn’t find similar keys, but maybe there is some kind of analogue to the find utility? Or some other way from the command line to perform the operation.

  • Something in my mind is going in the direction of "is it not easier to write a script in linqpad" ... - AK ♦
  • Use, say, FORFILES . - Akina

1 answer 1

In PowerShell:

 Get-Item C:\SomeFolder\* | where CreationTime -lt 01.01.2017 | Remove-Item