How to batch delete files on Windows 10
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 will delete all the 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.
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 subfolders 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 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".
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.
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 "enteryourpathhere" with the directory path.
cd C:enteryourpathhere del * /S /Q rmdir /S /Q C: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.
You should read it
- Delete the most 'stubborn' files on Windows
- How to Delete a File in Microsoft Windows Using Batch Files
- How to batch rename files on Windows without software
- Delete files on Mac directly without the Trash trash
- How to add trash to permanently delete files on Windows 10/11
- 5 software to rename files in batch
- 5 IF commands help use Batch script smarter
- How to move files by type in Windows with batch files
- How to view recently deleted files on Windows 10?
- 2 ways to permanently delete files on Windows
- How to Delete DLL Files
- How to Delete Files That Cannot Be Deleted
Maybe you are interested
9 ways to fix the error of not being able to save files as JPEG or PNG in Photoshop
Download standard and beautiful Word file experience initiative cover template
How to use the file search command on Windows, find saved files
How to split sheet into multiple separate Excel files
How to merge PDF files, merge and join multiple PDF files into a single file
How to clean up iPhone junk, delete junk files to free up iPhone storage