How to Delete a File or Folder Using CMD?
Last Updated : 16 May, 2024
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.
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.
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-
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 Search Files using CMD?
Ever lost a file on your computer and wished there was a quick way to find it without clicking through endless folders? Say hello to the Windows Command Prompt (CMD) a powerful little tool that can help you search for files fast. In this how-to blog, we will explore the steps to search for files usi
5 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 Create a File in CMD
We all know that one can easily create files using GUI options, but what if you can use a faster way to create files through the command-line interface? This is not a necessary but useful skill for anyone working with Windows. Whether you're automating tasks, working on scripts, or preferring using
5 min read
How to List all Files in a Directory using CMD
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
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
4 min read
How to Create a Batch File in Windows?
A batch file is a straightforward text document in any version of Windows with a set of instructions meant to be run by Windows' command-line interpreter (CMD) by maintaining all the functions. Batch files are a great tool for streamlining internally configured processes, automating tedious jobs, an
5 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
How to Delete Temporary Files in Windows 10?
Over time, temporary files in Windows 10 can accumulate and take up valuable disk space, potentially slowing down your system. These files are usually created by various applications for short-term use, but they can linger long after they're needed. Knowing how to delete temporary files in Windows 1
7 min read