I was able to run the script below but doesn't remove any directories I know I am missing something for the directories?

REM Remove files older than 14 days
forfiles -p "M:\14DAYTEMP" /q /s /m *.* /c "cmd /c Del @path" d- 14
forfiles /p "M:\14DAYTEMP" /s /m *.* /c "cmd /c  if @ISDIR== TRUE RD /q @FILE &RD /Q /S @FILE" d- 14
0 Comments   [ + ] Show Comments

Comments

Please log in to comment

Answers

1
What do you mean by practice I am able to remove any files within the directories but no the directories/folders themselves?

Thank you.
Answered 10/20/2014 by: stevobasquez
Senior White Belt

Please log in to comment
1
After deleting the files in a directory, you need to make sure that the current directory in your code is not the directory you are trying to remove. You cannot delete a directory that is held locked by ANY other process.
Answered 10/21/2014 by: EdT
Red Belt

Please log in to comment
0
If the directory is not empty then it cannot be deleted. Have you checked for this in practice?
Answered 10/20/2014 by: EdT
Red Belt

Please log in to comment
Answer this question or Comment on this question for clarity