How to Delete a File or Folder Using CMD?

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 the UsingCommand Prompt of Windows.

Table of Content

  • Methods to Delete Files and Folders Using Command Prompt
    • Method 1: Delete Files or Folders on CMD using DEL Command
    • Method 2: Delete Files or Folders on CMD using RMDIR Command
  • Delete a Folder and Subfolders in Command Prompt

Methods to Delete Files and Folders Using Command Prompt

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

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

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.

Delete a Folder and Subfolders in Command Prompt

Step 1: Open Command Prompt.

Step 2: Navigate to the directory where the folder you want to delete is located using the cd command.

Command:   cd <FolderName>

Step 3: To delete a single folder, use the following command.

Command: rmdir <FolderName>

Step 4: To delete a folder and all its subfolders and files, just include “/s” in between the rmdir and <folderName>, use the following command.

Command: rmdir /s <FolderName>

Step 5: Press Enter to execute the command.

Also Read

Conclusion

In this article, we explored how to use Command Prompt in Windows to delete files and folders efficiently when facing issues with File Explorer. We discussed two methods: using the DEL command to delete files and the RMDIR command to delete folders. Additionally, we provided a step-by-step guide on how to delete folders and subfolders using Command Prompt.

Delete File or Folder using CMD – FAQs

How to Delete a File or Folder on Windows?

  • For a file: Right-click the file and select “Delete” or use the “del” command in Command Prompt.
  • For a folder: Right-click the folder and select “Delete” or use the “rmdir” command in Command Prompt.

How do I force delete a folder in Command Prompt?

To force delete a folder in Command Prompt:

  • Open Command Prompt.
  • Navigate to the directory containing the folder using the “cd” command.
  • Use the “rmdir /s” command followed by the folder name to force delete it, along with all its subfolders and files.

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.



Contact Us