I try in my batch file o delete folder(BR) with many files and subdirectories, I try the following:
if exist C:\BR ( rmdir "C:\BR" /S /q )
but sometimes I get an error that a specific folder is not empty.these folder contains files of CSS. what the problem??
rd /s /q DIRNAME
rmdir /s /q DIRNAME
The files that you can't delete are in use.
Close whatever program is holding them open, probably your browser, and try again.
Let me guess, your trying to delete your %TMP%
folder.
EDIT: To answer zipi's question.
It will delete every file and folder that it can. So, if c:\tmp\dir2\dir3\open.txt
is open, c:\tmp\emptyDir
is an empty directory, and you do this:
c:\>dir c:\tmp /b /s
c:\tmp\a.txt
c:\tmp\dir2\b.txt
c:\tmp\dir2\dir3\open.txt
c:\>rd /q /s c:\tmp
c:\>dir /s /b c:\tmp
c:\tmp\dir2\dir3\open.txt
You will have deleted:
c:\tmp\a.txt
c:\tmp\dir2\b.txt
And removed:
c:\tmp\emptyDir
But still have the directories...
c:\tmp
c:\tmp\dir2
c:\tmp\dir2\dir3
...an the file:
c:\tmp\dir2\dir3\open.txt
If instead, a.txt
was open, you'd only have:
c:\tmp\
and
c:\tmp\a.txt
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With