Open In App

How to Delete a File or Folder Using CMD

Last Updated : 30 May, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

When working with files on Windows, File Explorer usually makes creating and deleting files simple. But what if File Explorer freezes or stops responding? In such cases, the Command Prompt (CMD) offers a reliable alternative. CMD allows you to create and delete files or folders using simple commands, even when File Explorer fails. In this article, we’ll walk you through the commands you need to delete files and folders using Windows Command Prompt. Methods to Delete Files and Folders Using Command Prompt

Methods to Delete Files or Folders in Windows Using Command Prompt

In the below section you will explore two methods to delete files and folders for Windows using CMD. So go through the methods and choose the right one.

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.

Steps to Delete a Folder and Subfolders in Command Prompt

Step 1: Open CMD

First open Command Prompt.

Step 2: Chosse Directory

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

Command:   cd <FolderName>

Step 3: Use RMDIR Command

To delete a single folder, use the following command.

Command: rmdir <FolderName>

Step 4: Delete Subfolders

To delete a folder and all its subfolders and files, just include "/s" in between the rmdir and <folderName>, use the following command and then press Enter.

Command: rmdir /s <FolderName>

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.


Next Article
Article Tags :

Similar Reads