Quantcast
Channel: Tech Support Guy
Viewing all articles
Browse latest Browse all 29110

Batch file deletes old folders but w/errors

$
0
0
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

Viewing all articles
Browse latest Browse all 29110

Trending Articles