How to Delete a File or Folder Using CMD
Last Updated :
18 Jul, 2025
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

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.
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.
Similar Reads
How to Rename Files and Folders Using CMD? Renaming files and folders is a fundamental task for system organization. While it's simple through the graphical interface, using CMD provides more flexibility, particularly for batch operations or when the interface is unavailable.In this guide, youâll master the ren (or rename) command, a built-i
4 min read
How to Compress or Extract files and folders using CMD? One effective technique to handle data without depending on third-party software is to use the Command Prompt (CMD) on Windows to compress and extract files and directories. To use CMD to compress files and directories, you must utilize the integrated 7z command-line tool. If you work with large fil
5 min read
How to Create Any File Using CMD: Learn 5 Methods Creating a file using Windows GUI is quite simple but did you know you can do the same using the Command Prompt (CMD)? This guide will walk you through multiple methods to create files directly from CMD, giving you more control and efficiency in managing your system.How to Create a File in CMDMethod
4 min read
How to Copy Files from One Directory to Another Using CMD Have you ever needed to copy a bunch of files from one folder to another without clicking through endless windows? Or perhaps youâre looking to streamline a repetitive task with a single line of text? If so, the Command Prompt (CMD) on Windows is here to save the day! Copying files between directori
5 min read
How to Format a Hard Drive Using the Command Prompt Formatting a hard drive is a common step when setting up a new disk or repurposing an old one. Although there are various methods to format in Windows, using the Command Prompt offers a fast and efficient option, particularly for advanced users.This article will show you how to format a hard drive u
4 min read
How to Hide files using Command-line Interface? If you're looking to hide files using the command line, it's a quick and efficient way to protect sensitive data on your system. Whether on Windows, macOS, or Linux, you can use the command line to hide files or folders with just a few simple commands. This guide will help you understand how to hide
3 min read