[batch-file] Batch file to delete folders older than 10 days in Windows 7

I want to create a batch file which should delete all subfolders of a folder which are older than 10 days, using Windows 7

Any help would be appreciated.

This question is related to batch-file

The answer is


Adapted from this answer to a very similar question:

FORFILES /S /D -10 /C "cmd /c IF @isdir == TRUE rd /S /Q @path"

You should run this command from within your d:\study folder. It will delete all subfolders which are older than 10 days.

The /S /Q after the rd makes it delete folders even if they are not empty, without prompting.

I suggest you put the above command into a .bat file, and save it as d:\study\cleanup.bat.


Similar questions with batch-file tag: