How to delete large folders in Windows super fast

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.

How to delete large folders in Windows super fast

windows super fast delete large folders

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.

  1. Tap on the Windows-key, type cmd.exe and select the result to load the command prompt.
  2. Navigate to the folder that you want to delete (with all its files and subfolders). Use cd path, e.g. cd o:\backups\test\ to do so.
  3. The command DEL /F/Q/S *.* > NUL deletes all files in that folder structure, and omits the output which improves the process further.
  4. Use cd.. to navigate to the parent folder afterwards.
  5. Run the command RMDIR /Q/S foldername to delete the folder and all of its subfolders.

The commands may require some explanation.

DEL /F/Q/S *.* > NUL

  • /F -- forces the deletion of read-only files.
  • /Q -- enables quiet mode. You are not ask if it is ok to delete files (if you don't use this, you are asked for any file in the folder).
  • /S -- runs the command on all files in any folder under the selected structure.
  • *.* -- delete all files.
  • > NUL -- disables console output. This improves the process further, shaving off about one quarter of the processing time off of the console command.
Read also:  Manage Windows users with Net User

RMDIR /Q/S foldername

  • /Q -- Quiet mode, won't prompt for confirmation to delete folders.
  • /S -- Run the operation on all folders of the selected path.
  • foldername -- The absolute path or relative folder name, e.g. o:/backup/test1 or test1

Creating a batch file and adding it to the Explorer context menu

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 OFF
ECHO Delete Folder: %CD%?
PAUSE
SET FOLDER=%CD%
CD /
DEL /F/Q/S "%FOLDER%" > NUL
RMDIR /Q/S "%FOLDER%"
EXIT

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.

delete folders quickly

Do the following to add the new batch file to delete folders quickly to the Windows Explorer context menu.

  1. Tap on the Windows-key, type regedit.exe and tap in the Enter-key to open the Windows Registry Editor.
  2. Confirm the UAC prompt.
  3. Go to HKEY_CLASSES_ROOT\Directory\shell\
  4. Right-click on Shell and select New > Key.
  5. Name the key Fast Delete
  6. Right-click on Fast Delete, and select New > Key.
  7. Name the key command.
  8. Double-click on default of the command key.
  9. Add cmd /c "cd %1 && delete.bat" as the value.

fast delete

 

Summary
Article Name
How to delete large folders in Windows super fast
Description
Find out how to delete huge folders with thousands of files and folders super fast on any version of the Microsoft Windows operating system.
Author
Publisher
Ghacks Technology News
Logo
Advertisement
Please share this article

Facebooktwittergoogle_plusredditlinkedinmail


Filed under:


Responses to How to delete large folders in Windows super fast

  1. Jeff July 18, 2017 at 10:26 am #

    Try deleting using PerigeeCopy's Delete function? How fast is it?

  2. Thorky July 18, 2017 at 11:05 am #

    Great! Thank you! :)

  3. CHEF-KOCH July 18, 2017 at 11:27 am #

    del /f/s/q foldername > nul
    rmdir /s/q foldername

    fatest way ... deleting ~30GB/1,000,000 files/15,000 folders: rmdir takes ~2.5 hours, del+rmdir takes ~53 minutes.

    https://superuser.com/questions/19762/mass-deleting-files-in-windows/289399#289399

    • HK-Rapper July 18, 2017 at 12:51 pm #

      I wish we could finally move away from NTFS after 24 years and embrace something new. Whatever happened to the intention to allow ReFS(Protogon) on Desktops than just servers.

  4. CHEF-KOCH July 18, 2017 at 1:01 pm #

    You can install ReFS on Desktops too but there is not much (noticeable) benefit using it, except that you get encryption problem.

    NTFS also gots in the 24 years several updates and I there are (like every protocol) some good and bad things, but deleting stuff isn't that bad compared to others.

    • HK-Rapper July 18, 2017 at 5:45 pm #

      If the only improvement is max volume- and filesize then it was another dud. Sure I cannot deny they take care of NTFS, but purely out of lack of having a real alternative. EXT4 will continue to outperform any MS filesystem.

      It is just that I would like something new. If the issues discussed here are not at least partially caused by the underlying FS, what else?

      • CHEF-KOCH July 19, 2017 at 3:04 am #

        Dunno what you want to improve but you as end-user not really mess with the file system ....

        There is no magic which makes you OS 20% faster because different file system, MAC OS recently rolled back to the older file system because the new one made trouble.

  5. Richard July 18, 2017 at 1:48 pm #

    @Martin Thanks for this. Very useful.

    In order to simply the registry changes, I exported the registry entries as .reg file and it can be downloaded from here https://1drv.ms/f/s!Ajyoa3dZEps6hewDvvyvozOJPc8xkg and merged (AKA installed) on a computer.

    • Mikhoul July 18, 2017 at 8:22 pm #

      👍👍👍

    • Matrix July 19, 2017 at 6:14 pm #

      Thanks man!!!

  6. chesscanoe July 18, 2017 at 2:45 pm #

    Thanks for the useful article. I enjoy going back to 1985 DOS techniques to get something efficiently accomplished.

  7. TelV July 18, 2017 at 4:07 pm #

    How strange! I tend to maintain the last three versions of system image which are usually about 45GB each. I delete the oldest one before creating a new one each month, but apart from the prompt informing me that I need Admin permission to delete it, the actual deletion process takes less than ten seconds.

    Maybe it's because each image is stored on an external drive (platter type) which makes the difference.

    • amplak July 18, 2017 at 4:19 pm #

      System image is often single file:)

      • dmacleo July 18, 2017 at 4:26 pm #

        bingo
        when you keep website backups locally you have tons (just the base program itself like wordpress or similar can have 5000) of small 1 to 2 kb php files, they each get deleted separately and take time.
        single iso/image files take seconds. I often delete 45gb bluray iso's, takes little time. a 5gb website backup takes a LOT longer.

      • Croatoan July 18, 2017 at 4:29 pm #

        Yes. One file 45GB takes few seconds, 5000 files 1 GB a few minutes.

  8. TelV July 18, 2017 at 4:41 pm #

    There are a few options mentioned in the following blog which purport to delete several thousand files in seconds rather than hours: http://mattpilz.com/fastest-way-to-delete-large-folders-windows/

  9. jasray July 18, 2017 at 6:53 pm #

    A rather old post, but I would much prefer to see something a bit more comprehensive:

    https://www.raymond.cc/blog/12-file-copy-software-tested-for-fastest-transfer-speed/2/

    Yes, these are copy utilities, but most have delete capabilities. Fast Copy is good for all things with an updated version:

    https://ipmsg.org/tools/fastcopy.html.en

    No mention of Linux--say, boot into a Live distro and delete files.

    No mention of the inherent bias of the hardware in use. Does it matter? Difference in deletion from a SSD versus a HDD and the processor in use? No idea . . . .

    An article still bound by utilities offered by Windows--does anything change with a third party program? Like boosting acoustical quality with DFX or some such tool?

    Por la tanto . . . .

  10. Emil July 18, 2017 at 8:38 pm #

    Why, RMDIR /S will delete files in subdirectories anyway. Instead of three lines the last one is actually enough.

    No idea what Explorer does with deletion jobs either, it's a bit sad...

  11. Berlin July 18, 2017 at 9:16 pm #

    Hi Martin I have coded a small vbs script to simplilfy the whole process , if someone wants to add the Fast Delete Option to his Folder context menu he can just download and unzip the following file and use the "Fast_Delete.vbe"
    https://goo.gl/7KTjjv
    Note: first click will add the fast delete Option and second click will remove the fast delete option

  12. Doc July 19, 2017 at 12:19 am #

    A slightly shorter alias for RMDIR is RD.

    C:\Windows\System32>rd /?
    Removes (deletes) a directory.

    RMDIR [/S] [/Q] [drive:]path
    RD [/S] [/Q] [drive:]path

    /S Removes all directories and files in the specified directory
    in addition to the directory itself. Used to remove a directory
    tree.

    /Q Quiet mode, do not ask if ok to remove a directory tree with /S

  13. recuva July 19, 2017 at 12:37 am #

    Seems similar to using [Shift + Delete] key combination which omits the recycle bin, is it?
    However, the files and folder will still reside on the drive and easily recovered until overwritten by new files, or by old files growing in size, overwriting of the old content there's still no quick way afaik.

  14. CHEF-KOCH July 19, 2017 at 2:56 am #

    RD should't be used since it's slower.

  15. oh well July 19, 2017 at 7:57 am #

    keeping backups in archives =?

  16. Mountainking July 19, 2017 at 8:36 am #

    How about using shift+delete @martin? Is super fast for me.....

    • Martin Brinkmann July 19, 2017 at 11:09 am #

      It should not be super fast if the folder is huge (meaning lots of files and folders inside).

  17. George October 14, 2017 at 6:07 pm #

    Brilliant, thank you for the tip.

  18. kjstech October 16, 2017 at 3:19 pm #

    I tried putting this in a context command but it didn't work. It splattered "Access denied..." a million times in a command window.

    I found I have to right click cmd, run as admin, navigate into the folder that I want deleted, then run delete.bat.

    I know it sucks, even when your logged in as an admin, Windows Server 2012 R2 still doesn't treat you like one.

    I'm not sure how to do a right click and select "run as administrator" to get the UAC box to pop up all in a registry command.

Leave a Reply