Deleting large numbers of old files on Windows

joyinspringwatermarked

When you have a large quantity of files to delete, it can be unwieldy doing this via the Windows interface.  You can open up a command window in administrative mode (in case administrative mode is needed to delete some of the files you want to delete) and issue the following command:

forfiles /p "d:\Temp" /s /m *.* /D -10 /C "cmd /c del @path /F /Q"

/p = the path to file files
/s = look in subfolders
/m = file mask to match when looking for files
/D - = search for files n days before current date
/C = the command to execute on the files
cmd /c = precede the command with this
del = delete the file
/F = force deletion of read-only files
/Q = don't ask to confirm deletion when using a wildcard

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s