How to mass delete files with cmd?

There are many reasons why you may want to mass delete a large number of files on your Windows computer. Perhaps you want to clear out old backups or temporary files that are taking up space. Or maybe you want to delete the contents of an entire folder. Doing this manually for hundreds or thousands of files would be extremely tedious. Fortunately, Windows provides a powerful command line tool called CMD that allows you to delete multiple files quickly and easily with just a few keystrokes.

In this guide, we will walk through the steps for mass deleting files using CMD commands. We will cover:

  • Opening the Command Prompt
  • Navigating to the target folder
  • Deleting all files in a folder
  • Deleting files based on extension
  • Deleting files older than a certain date
  • Deleting read-only files
  • Permanently deleting files
  • Undoing a deletion

Following these simple commands and techniques will allow you to clean up your storage drives by easily deleting large batches of unneeded files.

Opening the Command Prompt

The first step to using CMD commands is opening the Command Prompt window. Here are two quick ways to open it:

  • Press the Windows key + R to open the Run dialog box. Type “cmd” and hit Enter.
  • Open the Start menu and search for “Command Prompt”. Click on the Command Prompt app icon.

This will open up a command line window ready for entering deletion commands.

Running CMD as Administrator

For deleting system files or files in protected folders like Program Files, you may need to run CMD as administrator. Here’s how:

  • Open the Start menu and search for “Command Prompt”
  • Right-click on the Command Prompt app icon
  • Select “Run as administrator” from the popup menu
  • Click Yes on the User Account Control prompt

The CMD window will open with admin privileges, allowing you to delete anything. Be careful not to accidentally delete important system files!

Navigating to the Target Folder

Once the Command Prompt window is open, you’ll need to navigate to the folder containing the files you want to delete before running deletion commands. Here’s the basic syntax:

cd [drive:][path]

For example, to navigate to the Windows folder on your C drive:

cd C:\Windows

You can use “cd ..” to go up a folder level.

Tab auto-completion can help speed up navigating by finishing folder names when you start typing then hit Tab.

Once you’re in the target folder, you’re ready to delete files.

Deleting All Files in a Folder

To instantly delete every file within a folder, use the DEL command with the /S and /Q switches:

del /S /Q *

Let’s break this down:

  • del – The delete command
  • /S – Deletes all files in all subfolders
  • /Q – Quiet mode, doesn’t ask for confirmation before deleting
  • * – Wildcard representing all files

So this will delete every file in the current folder and its subfolders without prompting. Dangerous but very efficient!


Navigate to C:\Temp then run:

del /S /Q *

This will instantly obliterate all files in the Temp folder and subdirectories without confirmation. Use with caution.

Deleting Files by Extension

You can delete groups of files sharing a common extension very easily. The DEL command accepts wildcards like * and ? for basic pattern matching.

For example, to delete all .tmp files in the current folder and subfolders:

del /S *.tmp

Some other examples:

  • del /S *.bak – Delete all .bak files
  • del /S *.log – Delete all .log files
  • del /S *.temp – Delete all .temp files

Pretty handy for clearing out files types that tend to build up like logs and temporary files.


Navigate to C:\Users\YourUser\AppData\Local then run:

del /S *.tmp

This will delete all .tmp files from your user’s AppData\Local folder and subfolders.

Deleting Files Older Than a Certain Date

Deleting files by creation or modification date is handy for clearing out really old files you don’t need anymore. The DEL command accepts a /D switch for minimum age of files to delete.

For example, to delete files older than 30 days in the current folder and subfolders:

del /S /D -30 *.*


  • /D – Minimum age of files to delete
  • -30 – Delete files 30 days old or older
  • *.* – Match all files

You can change -30 to any negative number, like -90 to delete files older than 90 days.


Navigate to C:\Windows\Logs then run:

del /S /D -7 *.*

This will delete log files older than 7 days in the Windows\Logs folder and subfolders. Helpful for clearing out old logs.

Deleting Read-Only Files

Sometimes you may want to delete files that have the read-only attribute enabled. The DEL command won’t delete these by default. You can force deletion of read-only files with the /F switch:

del /F /S /Q *.*

The /F option will forcibly delete read-only files along with the rest.


Navigate to C:\Program Files then run:

del /F /S /Q *.*

This will forcibly delete all files from Program Files and subfolders, ignoring the read-only status. Use extreme caution with this!

Permanently Deleting Files

Normally, the DEL command moves deleted files to the Recycle Bin allowing you to restore them. However, you can completely obliterate files bypassing the Recycle Bin using the /P switch:

del /S /Q /P *.*

The /P option performs a permanent delete, preventing recovery. Files are deleted instantly without confirmation.


Navigate to a folder containing private files like C:\Users\YourUser\Private then run:

del /S /Q /P *.*

This will instantly and permanently destroy all files in the folder and subfolders with no Recycle Bin record. Use with caution.

Undoing a Deletion

If you delete important files accidentally, all hope is not lost. As long as the Recycle Bin hasn’t been emptied, you can restore deleted files easily:

  • Open the Recycle Bin by double-clicking on the desktop icon or navigating to it in File Explorer
  • Select the files you want to restore
  • Click “Restore” on the Ribbon menu to restore to original location

If the Recycle Bin is already emptied, powerful recovery software may still be able to get files back by scanning the drive.

So that covers the key commands and techniques for deleting multiple files quickly with the CMD prompt. Here’s a quick recap of what you can do:

  • Delete all files in a folder with del /S /Q *
  • Delete files by extension e.g. del /S *.tmp
  • Delete old files beyond a certain date e.g. del /S /D -30 *.*
  • Delete read-only files with /F switch
  • Permanently delete bypassing Recycle Bin with /P

Used responsibly, these CMD commands are invaluable for cleaning up unwanted files quickly and efficiently. Just be very careful, especially when using wildcards which can unintentionally nuke important files. With great power comes great responsibility!


Being able to mass delete large numbers of files is critical for freeing up drive space by clearing out clutter. Doing this manually would be incredibly tedious. Thankfully, CMD provides powerful delete commands that can blast away thousands of files in seconds.

The key commands covered in this guide included DEL with /S for recursive subdirectory deletion and /Q for quiet deletion without confirmation. Wildcards like * and ? provide basic pattern matching to delete by extension or attributes. Switches like /F and /P allow deleting protected and permanently deleting files.

By combining DEL commands, switches, navigation and wildcards, you can precisely target the files you want to mass delete. Just be careful when running destructive commands like del /S /Q * and always have backups. With proper care, CMD delete commands can help keep your PC lean and clean.