I need to delete one folder containing other folders and files inside. I tried
rmdir commands but sometimes they fail with some error lines:
[PATH]: The directory isn't empty.
Is there any good alternative?
This happens to me a lot with my automated build scripts.
I guess the reason might be some application that has a file open in that directory with "share delete". I.e. the application allows a deletion of the file (which is why I figure the DeleteFile call doesn't fail), but the file will only disappear after said application has closed it's handle.
That means the file might still be there when the
At least that's my theory.
The workaround proposed by Harry Johnston looks good. Only I would insert a pause in between the
So in total:
to skip confirmation messages.
You may have some readonly files, you can use the del /F option to get rid of them using
You could also have some hidden files and if you are really sure you want to delete them, then you can do this using
If this still fails, then either you do not have permission to delete some files, or some of the files are still in use.
I believe there's a bug in Windows 7 (and perhaps other versions) which sometimes causes this symptom; or it might be a bug in third-party software. (Do you have Symantec Endpoint Protection installed by any chance?)
Anyway, I've run across it fairly often. In most cases, the problem can be worked around by running
If this is in a batch file, you can do something like this:
To use the