How to Delete Folder Using Command Prompt in Windows

There are two ways in which a folder can be permanently deleted from the system using a command prompt. I have mention step by step instructions that can be used to delete a directory using the command line.

Many times the system doesn’t allow to delete a folder and show access denied message. You can remove the directory using the command line in this case and force the system to delete a folder and its contents.

Method I

To delete a folder located anywhere in the system use below command line:

1. Press Windows + R key to open the Run toolbox
2. Type cmd in the box and click on OK

Type cmd in Box

3. In the command prompt window, type:

  • rmdir /s <folder path>

Type rmdir/s folder path

or,

  • rd /s <folder path>

Type rd/s command folder path

where rmdir and rd stand for remove directory. /S command removes subfolders. Thus, it deletes the whole folder tree.

4. Press Enter.
5. The command line shows a message: Are you sure (Y/N)? ” Type Y to confirm the deletion of the specified folder.

Type Y or N to confirm deletion

  • If you do not want any confirmation message to appear for final deletion of a folder, then type:

rmdir /s /q < folder path >
or,
rd /s /q < folder path >

Folder path Command type rd/s/q

where q stands for quiet mode. Once /q command is typed in the command prompt, the command line ” < folder path >, Are you sure (Y/N)? ” does not appear and the folder gets permanently deleted.

Q Stands as Quiet Mode

  • If the folder path name contains spaces, then use quotations to specify location pathway in command prompt window. Type:

rd /s  “folder path” for deleting the folder after confirmation message appears
or,
rd /s /q “folder path” for no deletion confirmation message.

Folder path for no deletion confirmation

6. Then, press Enter.

This will delete the folder.

Also, learn how to logoff using command in Windows.

Method II:

To delete a folder on the desktop

  1. Press Windows + R key to open the Run toolbox
  2. Type the command line cmd in the box and click on OK button

Command Line cmd

3. In command prompt window, type cd /d C:\Users\<YourUserName>\Desktop

Command Prompt Window Type cd /d

4. Press the Enter key
5. Now, type dir /x and press Enter. This will show a list of all files and folders on the desktop.

Type Dir/x and press enter

6. Type rmdir /q /s <directory name as shown in command prompt window on the left side of folder name>
or, rd /q /s <directory name>

The directory name always has the navigation sign ~ in it. If there is no directory name, simply type the folder name as it appears on the command prompt window.

Type rd/q/s with directory name

7. Press Enter

I hope you find this command line useful to delete the directory from Windows operating system.

nv-author-image

Ankita

Founder and Writer @ WinOSBite. Future plan is to make this platform open to community to resolve and discuss various issues, usage related to Operating System.

Leave a Reply

Your email address will not be published. Required fields are marked *