Batch command for deleting both folders and contents order than 30 days

Solved/Closed
gmwenechanya Posts 2 Registration date Saturday 1 February 2020 Status Member Last seen 3 February 2020 - 1 Feb 2020 à 13:32
David Webb Posts 3177 Registration date Monday 25 November 2019 Status Member Last seen 15 May 2023   - 3 Feb 2020 à 09:45
Please help with Batch command for deleting both folders and contents order than 30 days , the command i have only deletes contents but not the folders
Related:

1 response

David Webb Posts 3177 Registration date Monday 25 November 2019 Status Member Last seen 15 May 2023   6,928
1 Feb 2020 à 17:08
Hello, a similar question was asked and answered in this forum post.

The best answer was the following:

Try the following command to automatically delete files at the root of a directory. This command can be saved in a .bat file and scheduled with scheduled tasks.

forfiles /p "PATH" /s /d -30 /c "cmd /c del @file : date >= 30 days >NUL"

Change "PATH" with the path where you want the files to be deleted. If there are no spaces in the path you dont need the "-symbol.


Let me know if that helps!

David Webb

Content Editor and Community Manager - CCM.net

gmwenechanya Posts 2 Registration date Saturday 1 February 2020 Status Member Last seen 3 February 2020
3 Feb 2020 à 09:01
Thank you so much...it worked!!!
David Webb Posts 3177 Registration date Monday 25 November 2019 Status Member Last seen 15 May 2023   6,928 > gmwenechanya Posts 2 Registration date Saturday 1 February 2020 Status Member Last seen 3 February 2020
3 Feb 2020 à 09:45
Brilliant! Happy to have helped!