Delete Files Older Than Date Using Batch Files

This problem has nagged at me for years. Here is a batch command to delete files on a Windows 2003 machine.

Forfiles -p z:\backup -s -m *.* -d -3 -c “cmd /c del /q @path”
This will delete all files in my backup directory older than 3 days. To test it first, use this:

Forfiles -p z:\backup -s -m *.* -d -3 -c “cmd /C Echo 0x22@Path\@File0x22”
This will print out each file that you will be deleting.

Was this post helpful?

Total Page Visits: 281 - Today Page Visits: 1