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.
Setting a folder to auto-deletebutton for the folder and select Settings. From the Folder Settings screen scroll down to Automated Actions>Delete or Unshare. Check the Auto-delete this folder on a selected date checkbox and choose a date you want the folder to be deleted.
Now that Command Prompt is open, use cd to change directories to where your files are. To delete a file, use the following command: del "<filename>" . For example, to delete Test file. txt , just run del "Test File.
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
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With