I created a batch file to delete folders older than 30 days. It works perfectly but with an error.. it will delete say 5 folders then there will be 5 lines of "ERROR: The system cannot find the file specified"
Here is my code:
ForFiles /P c:\folder\folder2 /s /D -30 /C "CMD /C if @ISDIR==TRUE echo RD /Q @FILE &RD /Q /S @FILE"
I am guessing the error is from the two "/s" in the code? What I need to do is find and delete all directories and subdirectories within the directory "Folder2" that are older than 30 days.
Any suggestions on where I went wrong? I am assuming the error is harmless but I would like to know why it is being generated.
Many Thanks!
Drew
Here is my code:
ForFiles /P c:\folder\folder2 /s /D -30 /C "CMD /C if @ISDIR==TRUE echo RD /Q @FILE &RD /Q /S @FILE"
I am guessing the error is from the two "/s" in the code? What I need to do is find and delete all directories and subdirectories within the directory "Folder2" that are older than 30 days.
Any suggestions on where I went wrong? I am assuming the error is harmless but I would like to know why it is being generated.
Many Thanks!
Drew