How to Delete a File or Folder Using CMD
Last Updated :
30 May, 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
Sed Command in Linux/Unix With Examples The SED command is one of the most powerful commands used during the process of text processing in Linux/Unix operating systems. The SED command is typically invoked for executing operations such as replace and search, text manipulation, and stream editing.With SED, you can manipulate text files wit
9 min read
How to Find the Wi-Fi Password Using CMD in Windows Forgotten your Wi-Fi password? Need to connect a new device but canât recall the complex string of characters? You donât have to scramble for that sticky note or reset your router just yet! Hidden within Windows is a powerful, built-in tool that lets you retrieve your Wi-Fi password quickly and secu
8 min read
How to Securely Copy Files in Linux | scp Command Secure file transfer is a crucial part of Linux systems administration. Whether moving sensitive files between local machines or transferring data between servers, or you need to move backup files to a remote server, fetch logs from a hosted machine, or sync directories across multiple systems, scp
10 min read
How to Download and Install the Google Play Store The Google Play Store is the heartbeat of your Android experienceâhome to millions of apps, games, and updates that keep your device functional, fun, and secure. But what if your phone or tablet doesnât have it pre-installed?In this step-by-step guide, youâll learn how to safely download and install
6 min read
How to Change Directories in Command Prompt (CMD) The Command Prompt (CMD) in Windows is a powerful tool for executing commands, managing files, and navigating your system. One of the most common tasks youâll perform in CMD is changing directories, which allows you to move between folders to access and manage files. But have you know how to change
11 min read
Create virtual environment in Python A virtual environment is a self-contained directory that contains a Python installation for a particular version of Python, plus a number of additional packages. Using virtual environments is a common practice in Python development as it helps to manage dependencies for different projects, avoiding
3 min read
'crontab' in Linux with Examples If you do manually backups , update logs, or restart services on your Linux machine? Imagine that running repetitive tasks overnight so your machine works for you while you rest. Here crontab, the native job scheduler in Linux, which enables users to easily automate commands, scripts, and system tas
9 min read
How to Clear DNS Cache in Chrome using chrome://net-internals/#dns Command If you're experiencing website loading issues, seeing outdated pages, or encountering network errors in Google Chrome, clearing your DNS cache (also known as host cache) might be the solution. This method is useful if you are facing problems like slow browsing speeds, site access errors, or incorrec
5 min read
ls Command in Linux The ls command is one of the most used commands in the Linux terminal to display the files and directories or path in the terminal. So, using the ls command is a basic skill for navigating the Linux file system, handling files, and managing directories.What is the ls Command in LinuxThe ls command i
10 min read
How to List all Files in a Directory using CMD in Windows Struggling to find or organize files buried in folders on your Windows PC? While File Explorer offers a visual way to browse, the Command Prompt (CMD) provides a faster, more powerful method to list, sort, and manage files, especially when dealing with large directories or automating tasks. In this
5 min read