Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

directory is not empty error

Tags:

batch-file

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??

like image 436
zipi Avatar asked Dec 04 '22 02:12

zipi


1 Answers

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
like image 116
James K Avatar answered Feb 20 '23 08:02

James K