How to use CMD to Delete a File or a Folder

July 19, 2023 / How-to Guide

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:

  1. Let us create a folder and a file on the desktop to delete it using CMD, as shown in the image below.
    file and folder
  2. The following are the commands used to delete a specific file or a folder and directly places then into the recycle bin-
    1. del
    2. rmdir
  3. Using “del” command-
    1. This is the command used to delete a file. Let us try to delete our created file “Extra.docx” from the desktop using CMD.
    2. 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
    3. Now, enter the name of the file you wish to delete in the second line as given below:
      del Extra.docx
      del Extra.docx
    4. You will see the file deleted from the desktop.
      example
  4. Using “rmdir” command-
    1. 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.
    2. 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
    3. Enter the name of the folder in the next line:
      rmdir Example

      rmdir
    4. 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.

Spread the love