Delete directory/folder from command line

by admin on January 2, 2009

We can delete a directory or folder from command line using rmdir command. See syntax below

rmdir directoryname


C:\>rmdir emptydir
C:\>rmdir nonemptydir
The directory is not empty.
C:\>rmdir /S nonemptydir
nonemptydir, Are you sure (Y/N)? y

As you can see in the above examples, we need to use /S to delete a non empty directory.

To delete directory in quiet mode, without being asked for confirmation, we can use /Q switch.

rmdir /Q /S nonemptydir

We can also use ‘rd’ in place of ‘rmdir‘. Both names refer to the same command. This command works on Windows 2000, Windows XP, Server 2003, Vista and Windows 7.

Deleting directory with white spaces in the name :

You can specify the directory name in quotes. See the example below.

rmdir /Q /S "folder with spaces in the name"


To delete a directory, you should have appropriate access permissions on the directory. Otherwise you would get ‘Access denied’ error.

{ 27 comments… read them below or add one }

Anonymous February 9, 2010 at 2:50 pm



Anonymous March 31, 2010 at 9:18 am

thanks, I was looking for this!


Anonymous May 20, 2010 at 9:11 am



Anonymous June 13, 2010 at 1:48 pm

Thank you very much


Anonymous June 22, 2010 at 3:56 pm

tanx buddy…..


Anonymous August 27, 2010 at 10:23 am

Thank you my friend


Brian November 26, 2010 at 2:05 pm

Thanks dude..I was looking for command line way of deleting nonempty folders.. cheers!!!


Anonymous January 13, 2011 at 4:35 pm

good post ……..


Anonymous February 15, 2011 at 5:30 am

Good old DOS….something tells me one day the world will be saved by a DOS operation. ; )


Anonymous July 23, 2011 at 8:40 am

cannot delete… access is denied. am trying to delete a directory on a flash drive. cannot access permissions because explorer isn't working. using win7


Diman December 15, 2011 at 4:09 am

Don’t forget to leave a “space” in the command line..
rmdir /Q /S_“folder with spaces in the name” I meant “space”, ait’t “underscore”. And upper case of “S”. Good luck!


chetan January 9, 2012 at 1:04 am

can you show me an example of command to delete this path in bat file.
C:\Program Files\Microsoft Office Communicator

am not able to do this . some error s


admin February 2, 2012 at 4:19 pm

Is this in Windows 7/Vista?.
If so then you need to take ownership of the files. You can do that with below command from elevated administrator command prompt.
takeown /F "c:\Program Files\Microsoft Office Communicator" /R /A

then run the below command to delete this folder.

rmdir /S "c:\Program Files\Microsoft Office Communicator"

Ashwani February 2, 2012 at 6:40 am

cd program files\microsoft office communicator
then enter press
rd /s “filename”
Then enter


Yoyi August 14, 2012 at 10:08 pm

Thank you so much! =D


Raj February 2, 2013 at 4:51 am

I am getting the following error “The process cannot access the file because it is being us
ed by another process.” what should be the case now?


Tito April 15, 2013 at 3:07 pm

Could you kindly post the command for deleting my folder which is at Drive G. Name of the folder is Recycler. Thanks


Andrew June 19, 2013 at 3:31 pm

Thank you so much. I was trying to delete an entire directory of files, about 200k folders and files, and it kept throwing a warning “this folder is shared with other people”. No such warning with this command!


Chauhan Nitin June 23, 2013 at 5:55 pm

i followed your instructions but i’m getting error to delete a folder in cmd. ERROR = The system cannot find the the specified…


Jun December 5, 2013 at 6:19 am

Thanks, it is very useful


Fahd June 3, 2014 at 2:06 pm

i have installed new win 8 n a back up of old win 8 is in c drive with a name windows old n its not being deleted by ANY means . i have tried this one as well but it says on all files access is denied


Bose June 18, 2014 at 6:14 am

I tried the process many times but it says “access is denied”….
My entire path is “C:\program files\alwil software\avast5″ . How should i delete this avast5 folder with all the folders inside it????????????


nick July 18, 2014 at 4:31 am

run cmd.exe as administrator
make sure avast service is not running

wrf November 7, 2014 at 9:08 pm

Every time I try it says the file cant be found


somu December 12, 2014 at 12:43 pm

you’re really awesome. Googled a 1000 times just for this line

“C:\>rmdir /S nonemptydir
nonemptydir, Are you sure (Y/N)? y”

Thank you so much for your help. This changed my life.


Dametew Buta March 31, 2015 at 4:16 am

Thank you so much for your help. This changed my life.
please attache more basic command for beginner person for my email


MAJ March 31, 2015 at 9:28 am

I need to do that help me out

D:\abc\ file and folder in it

but by using rd or rmdir

rmdir d:\abc\ /s /q will delete abc folder also but i dont want this.



Leave a Comment

HTML tags are not allowed.

Previous post:

Next post: