This guide explains how to use CMD to delete a file or a folder. If you find problem in deleting any file or folder by right-clicking, then you can use CMD for doing it.
Let us follow the steps to use CMD to delete a file or a folder:
- Let us create a folder and a file on the desktop to delete it using CMD, as shown in the image below.
- The following are the commands used to delete a specific file or a folder and directly places then into the recycle bin-
- del
- rmdir
- Using “del” command-
- This is the command used to delete a file. Let us try to delete our created file “Extra.docx” from the desktop using CMD.
- Change the path of the directory in command line and set the path of the file you want to delete. Enter the below command and press the enter key:
cd desktop - Now, enter the name of the file you wish to delete in the second line as given below:
del Extra.docx
- You will see the file deleted from the desktop.
- Using “rmdir” command-
- This is the command used to delete the complete folder or a directory. We will try deleting our created folder “Example” from the desktop using CMD.
- Change the path of the directory in command line and set the path of the folder you want to delete. Enter the below command and press the enter key:
Cd desktop - Enter the name of the folder in the next line:
rmdir Example
- You can check your desktop; your folder will be deleted.
This way, you can delete a file and a folder using CMD. Hope you liked our article and for such similar informative articles do contact our support staff at your earliest.