Open In App

How to Delete a File or Folder using CMD?

Last Updated : 12 Feb, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

While working on Windows devices, we used to work on Windows File Explorer for working with files. On File Explorer of Windows, the creation of new files as well as deleting old ones is one of the easiest processes. However, if your File Explorer is not responding, then the process to Delete Folder using CMD can be an alternative.

The Windows Command Prompt is the command line tool that executes different tasks with the help of Windows Commands. Using CMD in Windows, the File Creation for Windows can also be executed. If you are having trouble Deleting Files or Folders on Windows directly by right-clicking, then you can Delete files using CMD.

This article is going to discuss the commands required to Remove Files & Folders using Command Prompt of Windows.

Quick Preview to Delete File or Folder using CMD:

  1. Open Windows Command Prompt.
  2. Execute the command del <File Name>.txt
  3. Or run the command rmdir <File Name>

Methods to Delete Files or Folders using CMD

To Erase Windows Files or Folders using CMD, the following guidelines should be used properly. Let us start with the DEL Command Execution.

Method 1: Delete Files or Folders on CMD using DEL Command

Note: DEL Command is used to delete a file. Here, we will take our sample file “hello.txt” located on the desktop, and try to delete it using the del command in CMD. Follow the steps given below to delete the file:

Step 1: Change the Path of the Directory in CMD and set it to the path of the file. Type the following command and press Enter.

cd desktop

Step 2: Delete the file hello.txt with the following Windows Command.

del hello.txt

1--DEL-Command

Method 2: Delete Files or Folders on CMD using RMDIR Command

Note: RMDIR Command is used to delete the entire folder or directory. Here, we will take our sample folder named “Tasks” placed on the desktop and try to delete it using RMDIR Command in CMD.

Step 1: Change the Directory’s Path in Command Prompt and set it to the path of the folder.

cd desktop

Step 2: Delete the folder Tasks with the following command.

rmdir tasks

2--RMDIR-Command

From the above discussion, this should become clear that the Deletion of Windows Files using CMD is a matter of a few seconds. You have to just move inside the Windows Directory using the Windows CD Command. And then, as per your choice execute any one of the Windows File Deletion Commands in CMD.

Also Read

Frequently Asked Questions to Delete File or Folder using CMD

How to delete a file or folder using CMD?

The steps to delete a file or folder using CMD are the following.

  1. Open the Command Prompt by searching on the Search Bar.
  2. Execute the command del <File Name>.extension to delete the file.

How can I normally delete a file or folder on Windows?

To normally delete a file or folder on Windows using File Explorer, the steps are below.

  1. Open File Explorer.
  2. Navigate to the file or folder location.
  3. Select the file & press CTRL + D to delete it.

Is it safe to use CMD for the file deletion process?

Yes! It is completely safe to use CMD for the file deletion process. Rather, you can use the CMD for every type of operation. If you delete a file using CMD, you will again see the file in the Recycle Bin. So, there is no change in the process, just there is no graphical attraction present like File Explorer.


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads