We can delete a directory or folder from command line using rmdir command. See syntax below
rmdir directoryname
Examples:
C:\>rmdir emptydir
C:\>
C:\>rmdir nonemptydir
The directory is not empty.
C:\>rmdir /S nonemptydir
nonemptydir, Are you sure (Y/N)? y
C:\>
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”
{ 14 comments… read them below or add one }
thnx.
thanks, I was looking for this!
thnx
Thank you very much
tanx buddy…..
Thank you my friend
Thanks dude..I was looking for command line way of deleting nonempty folders.. cheers!!!
good post ……..
Good old DOS….something tells me one day the world will be saved by a DOS operation. ; )
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
Note:
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!
Hi
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
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 /Athen run the below command to delete this folder.
rmdir /S "c:\Program Files\Microsoft Office Communicator"cd program files\microsoft office communicator
then enter press
rd /s “filename”
Then enter