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
3. In the command prompt window, type:
- rmdir /s <folder path>
or,
- rd /s <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.
- 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 >
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.
- 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.
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
- Press Windows + R key to open the Run toolbox
- Type the command line cmd in the box and click on OK button
3. In command prompt window, type cd /d C:\Users\<YourUserName>\Desktop
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.
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.
7. Press Enter
I hope you find this command line useful to delete the directory from Windows operating system.