Delete Files Using Windows Command Prompt: A Guide

Affiliate Disclaimer: If you purchase through links on our site, we may earn an affiliate commission at no additional cost to you!
Photo of author


Delete Files with Command

The Windows Command Prompt provides a powerful, direct way to manage files and folders on your computer. With just a few keystrokes, you can quickly delete unnecessary files, free up drive space, and keep your system running smoothly.

In this comprehensive guide, you’ll learn how to harness the Command Prompt to safely and efficiently delete files in Windows.

By the end of this guide, you’ll have the knowledge to leverage the Command Prompt as a file management Swiss Army knife on your Windows computer. Let’s get started!

What is the Command Prompt?

The Command Prompt, also known as the command line, is a text-based interface that allows you to access the underlying functions of Windows. It harkens back to the early days before modern graphical user interfaces.

Inside the Command Prompt window, you type text commands to perform tasks rather than using the mouse. It provides extra capabilities beyond what you can do visually in Windows File Explorer.

Why Use the Command Prompt for Deleting Files?

Here are some key advantages of using the Command Prompt for file deletion tasks:

  • Speed: You can rapidly delete multiple files by typing just a few commands. No time wasted opening folders and selecting files.
  • Power: Advanced deletion features like wildcards give you granular control over what gets deleted.
  • Safety: With proper care, Command Prompt deletion is less prone to accidental data loss versus visually managing files.
  • No Recycle Bin: Files deleted via Command Prompt bypass the Recycle Bin for immediate, permanent removal.
  • Hidden Files: You can view and delete hidden system files not shown in File Explorer.
  • Troubleshooting: If Windows isn’t working properly, you can delete problem files using Command Prompt even if File Explorer isn’t responding.

For large-scale deletion tasks, the Command Prompt is hands-down the most efficient method on Windows.

Opening the Command Prompt

There are a couple quick ways to open the Command Prompt window on Windows:

  • Press Windows key + R to open the Run dialog box. Type cmd and press Enter.
  • From the Start menu, search for “Command Prompt“, right-click on it, and select Run as administrator. This opens the app with admin privileges.
  • Go to Start > Windows System > Command Prompt
  • From File Explorer, navigate to the folder you want, hold Shift, right click inside the window and select Open command window here

Once open, you’ll see a blank window ready for typing commands.

Before deleting files, you need to be able to get around the Command Prompt interface comfortably. Here are the main commands for basic navigation:

  • cd PATH – Changes the current directory to specified PATH. For example: cd C:\Users\Max\Documents
  • cd .. – Go up one folder level.
  • dir – List contents of current directory.
  • mkdir NAME – Makes a new folder named NAME.
  • cls – Clears the Command Prompt screen.

Use cd and dir to move to the folder containing the files you want to delete before running the deletion commands.

Tip: You can drag and drop folders from File Explorer into the Command Prompt window to auto-fill the folder path.

Using DEL to Delete Files

The DEL command is used to delete files and folders in the Command Prompt. The syntax is simple:

del fille.txt

For example, to delete a file named notes.txt in the current folder, you’d type:

DEL notes.txt

Hit Enter and that file is gone for good!

Make sure you’re in the correct folder before running the DEL command, or provide the full path like:

DEL C:\Users\Max\Documents\notes.txt

You can delete multiple files simultaneously too:

DEL file1.jpg file2.jpg file3.jpg

The DEL command works on files, folders, and subfolders in Command Prompt. But there’s no recycle bin recovery, so double check your typing before hitting Enter!

Using Wildcards for Advanced Deletion

Wildcards let you delete groups of files matching a pattern rather than typing every filename. This is extremely useful for mass deletion tasks.

The * wildcard symbol matches any sequence of characters. For example:

del C:\Users/username/Desktop/*.wav
DEL *.temp

This will delete all files ending in .temp in the current folder. Other examples:

  • DEL *.txt – Delete all text files
  • DEL Data_File_* – Delete any files starting with Data_File_
  • DEL *.jpg *.png – Delete all JPG and PNG image files

You can combine the * wildcard with paths to delete files and folders:

DEL C:\Users\Max\Documents\Notes_*

This will remove any folders starting with Notes_ inside the Documents folder.

With wildcards, you can delete huge batches of unnecessary files very quickly.

Deleting Hidden Files

Hidden files don’t display in Windows File Explorer, but you can view and delete them via the Command Prompt.

First, type DIR /A to list all files, including hidden ones. Then to remove them, add the /A switch to DEL:


Deleting hidden system files could cause problems if you remove the wrong ones, so be cautious.

Tip: You can unhide files in File Explorer by going to View > Options > Change folder and search options. Then under the View tab, check “Show hidden files, folders, and drives“.

PS: Here, you can fix the AMD Quick Stream issue.

Emptying the Recycle Bin from Command Prompt

Normally, deleted files from File Explorer go to the Recycle Bin, where they can be recovered. But with the Command Prompt, deleted files skip the Recycle Bin entirely.

If you need to manually empty the Recycle Bin, type:

DEL %SystemDrive%\$Recycle.bin /S /Q

This will permanently remove all deleted files without recovery. Don’t run it unless you’re certain.

Besides, you will learn more about how to empty the Recycle Bin.

Deleting Folders with RD and RMDIR

While DEL removes individual files, it can’t delete entire folders. For that you need the RD or RMDIR commands.

To delete a folder named Notes in the current directory:

RD Notes



Both RD and RMDIR work the same. The folder must be empty before you can delete it.

To remove a folder and its contents recursively, add the /S switch:

RD /S Notes

This will delete the Notes folder and everything inside it. Use caution as this can quickly nuke large chunks of data.

Tips for Power Users

Here are some extra Command Prompt tips for deleting files like a pro:

  • Add the /Q option to DEL or RD commands to disable confirmation prompts for each file deletion.
  • DEL *.* will mass delete all files in a folder regardless of extension.
  • DEL /F forces deletion of read-only files.
  • DEL /S deletes all files in the specified folder and its subfolders.
  • Open Command Prompt as admin using “Run as administrator” to delete protected system files.
  • Utilize the FOR command to execute DEL commands on a list of files contained in a text file. Very useful for batch jobs.

Take it slow when learning advanced functions -tiny typos can have big consequences! But once mastered, you’ll have incredible power to manage disk space.

Recovering Deleted Files

Since files deleted with the Command Prompt bypass the Recycle Bin, recovery becomes difficult. Your best bet is a dedicated Windows file recovery program like Recoverit:


Recoverit can restore files deleted from the Command Prompt, Recycle Bin, partitions, hard drives, USB drives, memory cards, cameras, and more. Follow these steps for the best chance of getting lost files back:

  1. Stop – Don’t save anything new to the drive with deleted files.
  2. Scan – Run Recoverit and scan the drive to find recoverable files.
  3. Preview – Filter through found files to locate your deleted data.
  4. Recover – Save the rescued files to a safe location.

As long as the original space hasn’t been overwritten, you have a strong chance of recovery with Recoverit. Don’t hesitate to contact Recoverit technical support if you need assistance.

Key Takeaways

Here are the core lessons for successfully deleting files via the Command Prompt on Windows:

  • Open Command Prompt by typing cmd in the Run dialog or Start menu search.
  • cd and dir help you navigate folders. del deletes files and folders.
  • Use wildcards (*) to mass delete certain types of files.
  • Add /S and /Q options to del for advanced commands.
  • RD and RMDIR delete empty folders. /S removes folders and contents.
  • Deleted files don’t go to the Recycle Bin. DEL /F bypasses read-only status.
  • Be cautious when typing delete commands. DEL /? gives help.
  • Have a recovery plan ready with software like Recoverit in case you make a mistake.

Learning Command Prompt file deletion takes some practice, but mastering it will give you more power and productivity in Windows. Take it slow and refer to this guide whenever you need a quick refresher. Happy deleting!

Frequently Asked Questions

Here are answers to some common questions about deleting files with the Command Prompt:

Q: Can I recover a file I accidentally deleted with the Command Prompt?

A: Unfortunately no. Unlike deleting through File Explorer, files removed with the Command Prompt bypass the Recycle Bin entirely. Your best bet is using recovery software like Recoverit to scan the drive and rescue deleted files before they’re overwritten.

Q: Do RD and DEL commands work the same in Windows Command Prompt and Powershell?

A: Yes, RD, DEL and other file deletion commands function the same in Command Prompt and Powershell on Windows. The core syntax does not change between the two interfaces.

Q: What happens if I delete System32 or other critical Windows folders with the Command Prompt?

A: Deleting vital system folders like System32 via Command Prompt can severely break Windows and prevent booting. You should never delete these folders unless you know exactly what you are doing.

Q: Can I schedule the Command Prompt to delete files and folders automatically?

A: Yes, you can create batch scripts that run DEL commands and schedule them using the Windows Task Scheduler. This allows automating large deletion jobs.

Q: Is there an UNDELETE command to recover files I removed with the Command Prompt?

A: Unfortunately no, there is no UNDELETE command built into the Windows Command Prompt. Once deleted with DEL, the only way to recover the files is via data recovery software.

Q: What is the best command to permanently wipe sensitive files?

A: To securely erase sensitive files making them unrecoverable, use the cipher /w command. This overwrites data beyond recovery. Make backups before running it.

Q: Can I undo a deletion right after running a DEL command in Command Prompt?

A: No, there is no undo function after deleting files with DEL. The files are immediately removed with no Recycle Bin recovery. Your only option is to restore from a backup or attempt data recovery.

Q: Is it safe to delete very large folders containing tons of files using Command Prompt?

A: Yes, it is technically safe if you use the correct commands, but deleting enormous folders recursively via Command Prompt can take a long time to process. It may be faster to manually delete in small chunks.

I hope these tips help you become an expert at harnessing the Command Prompt to safely delete files on your Windows computer! Let me know if you have any other questions.

Also, here you will find out how to fix the directory name is invalid issue.


Skilled software testing specialist with expertise in comparisons and research, passionate about blogging, reviews, and creating video tutorials.

More Articles

Repair, Windows

How to Fix 0x8024001E Error on Windows Store Easily?

0x8024001E is an error that relates to Windows Store. As you may already know, Windows Store is a relatively new ...
Repair, Windows

How to Resolve Data Loss Due to Windows 0xc1900101 Error

Data recovery is the process of recovering data that was lost due to physical damage, deletion, and/or formatting. As personal ...
Please Wait For The Gpsvc
Repair, Windows

A Guide to “Please Wait for the GPSVC” Issues – Overcoming the Hurdle

What exactly does the “please wait for the GPSVC” message mean? How can I get rid of this message on ...