Link to home
Create AccountLog in
Avatar of detox1978
detox1978Flag for United Kingdom of Great Britain and Northern Ireland

asked on

rmdir /s /q "The directory is not empty."

Hi All,

I want to delete a folder and all its sub folders using a windows command line.

I had been using

rmdir /s /q "C:\MyFolder"

Open in new window


this returns "The directory is not empty."


Any idea how I can get it to delete the content regardless of it not being empty??
Avatar of rl3
rl3
Flag of United States of America image

If i remember correctly rmdir is only one level for actual folders so it will only work if all subfolders have been deleted.  check to make sure there are no subfolders under the folder you are removing.
ASKER CERTIFIED SOLUTION
Avatar of Kyle Abrahams, PMP
Kyle Abrahams, PMP
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
rmdir will work with empty subfolders.

rmdir /s will also work for subfolders having files (just tested).

Only thing I can think of is there's a file lock of some kind on one of the files?
Avatar of detox1978

ASKER

I'm using rmdir, but it returns the error "The directory is not empty."
are there any files left in the directory?

What happens if you try the delete?

WHat OS?
Avatar of Bill Prew
Bill Prew

See what files are displayed by:

dir /s /b "C:\MyFolder"

it may give you a clue as to what files were not able to be deleted.  Once files are encountered that can not be deleted (open and locked, long filenames, etc) then none of the parents folders of that file can be deleted.

~bp
del "C:\MyFolder\*" worked, thanks.  I guess there was a file it didnt like.
IOS Terminal

rmdir --ignore-fail-on-non-empty foldername