» about » content »

How to automatically delete old files in windows

Occasionally I need to write a Windows batch file to automatically clear out old files, so I'll post this here as a reminder (mainly to myself).

rem to test without deleting: forfiles -p "C:\backups" -s -m *.zip -d -7 -c "cmd /c echo @FILE"

forfiles -p "C:\backups" -s -m *.zip -d -7 -c "cmd /c del @FILE"

Here's more info on the above.

© Roqet :: 2021-06-01 11:09:01