How to batch delete files on Windows 10

How to batch delete files on Windows 10

Deleting anything more than a few files with File Explorer can become a lengthy process. When it comes to batch deletion of files on Windows 10, you have a few options.

1. Batch delete files by Command Prompt

Command Prompt has two powerful file deletion commands: DEL and rmdir.

DEL is quite easy to understand is the command to delete a file, while rmdir is the command to delete the entire directory. You can add parameters to both commands to delete and remove specific file types, or simply delete everything.

Warning:

The rmdir command is very powerful and potentially dangerous. It removes the entire directory, including the file structure and everything in it. If you delete an important folder using this command by mistake, you may have to reinstall Win.

Delete a single file

To delete a file, use the following command:

del C:enteryourpathhere /f /s

The basic command locates the specified directory, while the / s parameter deletes all files contained in the subdirectories, and the / f parameter ignores any read-only settings.

Alternatively, go to the folder containing the files you want to delete, press Shift + Right click and select Open a command window here . Then, type “del [filename]” and press Enter.

  • 6 ways to permanently delete files on Windows

Delete a specific file type

What if you want to delete a specific file type from a directory? You can do that by using the following command:

del * .extension

Change “extension” to the file type you want to delete.

You can extend the command to remove all specific file extensions from subdirectories with the addition of some parameters:

del /s /q *.extension

Alternatively, if you want to delete multiple file types, you can add multiple types of extensions:

del /s /q *.png *.svg
Delete a specific file type

Delete files and folders

The preceding commands leave the file structure behind, which can be frustrating if you want to batch delete everything. If you want to delete folders with files, you can use the following commands:

del /f /s /q C:enteryourpathhere > nul rmdir /s /q C:enteryourpathhere

There are a few other parameters shown here. Nul is a special file that removes all data written to it, meaning that a somewhat time-consuming enumeration process will not be written to the file, while / q chooses “silent mode”.

  • Guide to find and delete duplicate files on Windows

2. Batch delete files using batch file

A cell batch file is a script you can run to perform certain tasks on your system. If you know how to create a sequence of commands, you can build a long script to automate tasks and save time. In this case, the article will use some basic commands to write batch delete commands.

For this example, we will delete the MUO Batch Rename folder we created for the previous examples. Right click on the desktop and go to New> Text Document . Name it BatchDelete and open it.

The batch file example requires you to know which directory you want to delete the file in. This sounds obvious, but you need the exact file path of the directory.

If you are unsure of the correct path for the folder, right-click and choose Properties , see the location there. Or, browse to the folder and click once in the address box to show the directory path directly.

  • Delete the most stubborn files on Windows

Either way, make sure you have the correct directory as it will be wiped from the system soon.

You can copy and paste the following into your batch file. You should replace “enter your path here” with the path to the directory.

cd C:enteryourpathhere del * /S /Q rmdir /S /QC:enteryourpathhere

After you copy, paste and add the path to the folder, choose File> Save . Now, find your BatchDelete.txt file and press F2 to rename the file. Change the file extension from .txt to .bat and press Enter when you get a warning.

Congratulations, you’ve just created your first batch file!

Please note that you will have to update the directory path when you want to use the batch file again.

2