A simple batch script to delete Files & Folders older than x days

The below deletes all files from c:temp older than 10 days:
FORFILES /p “c:temp” /m *.* /c “cmd /c Del /F /Q @path” /d -10 /s

The below deletes all folders from c:temp older than 10 days:
FORFILES /p “c:temp” /S /D -10 /C “cmd /c IF @isdir == TRUE rd /S /Q @path”

Share

Leave a Reply

Your email address will not be published. Required fields are marked *

2 × 3 =