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
- 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
May be interested
- How to clean and recover space on C drive Windows 10for most people, drive c is the core part of the pc. tipsmake will guide you on how to clean up drive c, recover some space, and then get this drive up and running again quickly.
- How to allow / deny an application access to the file system in Windows 10this guide will show you how to change privacy settings to allow or deny apps access to the file system for all users or just your account in windows 10.
- How to show the Taskbar on all monitors in a multi-monitor setupin a multi-monitor setup, windows allows you to display the taskbar on all monitors. this option can be configured using the settings app. here's how to do it.
- Microsoft stopped updating for Windows 10 1903 from December 8, 2020december 8, 2020, windows 10 version 1903 will receive the final cumulative update. from this date on, microsoft will end support for windows 10 version 1903.
- What is 'Optional Quality Update' on Windows 10?on windows 10, windows update can sometimes give you 'optional quality update'. unlike other updates, windows will not install these updates automatically. so what exactly are they? should you install them?
- How to turn off the automatic opening introductory after updating Windows 10if you're bothered, you can easily turn off the auto-opening of the introduction window after updating windows 10, so the experience will be more seamless.