When you delete huge folders in Windows, you will notice that the process takes quite a bit of time to complete.
I keep backup folders of Ghacks locally on a platter-based drive, and these folders come close to 30 Gigabytes in size with more than 140,000 files and 350 folders.
When I need to delete them again, it takes a long time if I run the delete operation in Windows Explorer. First thing that happens is that Windows runs calculations which in itself may take a very long time to complete.
Then when the actual deleting takes place, Windows analyzes the process and posts updates to the file operation window.
It may take ten or twenty minutes, or even longer, to delete a large folder using Explorer on Windows devices.
If you run delete commands from the command line instead, you will notice that the operation completes a lot faster. You may notice that the operation needs just a fraction of time that the same operation requires when you run it in Explorer.
Matt Pilz, who wrote about this back in 2015 saw a reduction from 11 minutes to 29 seconds, which made the command line operation more than 20 times faster than the Explorer option.
The downside to this is that it requires use of the command line. Matt suggested to add the commands to the Explorer context menu, so that users could run them in Explorer directly.
The two commands that users require are Del, for deleting files, and Rmdir, for removing directories.
The commands may require some explanation.
DEL /F/Q/S *.* > NUL
RMDIR /Q/S foldername
If you don't need to run the command often, you may be perfectly fine running the commands directly from the command prompt.
If you do use it frequently however, you may prefer to optimize the process. You may add the command to the Explorer context menu, so that you can run it from there directly.
First thing you need to do is create a batch file. Create a new plain text document on Windows, and paste the following lines of code into it.
ECHO Delete Folder: %CD%?
DEL /F/Q/S "%FOLDER%" > NUL
RMDIR /Q/S "%FOLDER%"
Save the file as delete.bat afterwards. Make sure it has the .bat extension, and not the .txt extension.
The batch file comes with a security prompt. This provides you with options to stop the process, important if you have selected the context menu item by accident. You can use CTRL-C or click on the x of the window to stop the process. If you press any other key, all folders and files will be deleted without any option to stop the process.
You need to add the batch file to a location that is a PATH environmental variable. While you may create your own variable, you may also move it to a folder that is already supported, e.g. C:\Windows.
Do the following to add the new batch file to delete folders quickly to the Windows Explorer context menu.
Advertising revenue is falling fast across the Internet, and independently-run sites like Ghacks are hit hardest by it. The advertising model in its current form is coming to an end, and we have to find other ways to continue operating this site.
We are committed to keeping our content free and independent, which means no paywalls, no sponsored posts, no annoying ad formats (video ads) or subscription fees.
If you like our content, and would like to help, please consider making a contribution:
Ghacks is a technology news blog that was founded in 2005 by Martin Brinkmann. It has since then become one of the most popular tech news sites on the Internet with five authors and regular contributions from freelance writers.