I needed a batch command to delete some backup files older than 7 days earlier, here is a simple batch command to do it, should work on any┬áversion of windows, you will need to download the forefiles.exe file and put it in folder you are running that batch file from first…

To delete files older than 5 days:-

Forfiles.exe -p c:backup -s -m *.* -d -5 -c “cmd /c del /q @path”

This will delete all files in the c:backup directory older than 5 days. To test it first, use this:

Forfiles.exe -p c:backup -s -m *.* -d -5 -c “Cmd /C Echo 0x22@Path@File0x22”