Remove old folders on Windows using batch script

I have found nice batch script which will remove all folders inside specific folder. This is good when you have some directory with automatic builds and want to remove old scripts from time to time.

ForFiles /P "BASE_FOLDER_PATH" /D -14 /C "CMD /C if @ISDIR==TRUE echo RD /Q /S @FILE &RD /Q /S @FILE"

Replace BASE_FOLDER_PATH with folder containing automatic builds and 14 with maximum number of days. Older folder will be removed.

Leave a Reply

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