How to delete large folders in Windows super fast
The fastest way to delete large folders and files in Windows is to take the command-line approach. You could either do it manually via CMD or create and run a batch file for quick deletion. These two methods are a lot faster than the traditional way of deleting using the Windows Explorer delete option.
But before I go through the superfast way to delete large folders, here’s the reason why it takes so much time. If you are in a hurry, jump to the next section for the solution.
Why Does Windows Take Time to Delete Large Folders?
When you delete huge folders in Windows, you will notice that the process takes quite a bit of time to complete. It is the opposite of fast.
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. The problem is that Windows prepares to delete first. This includes running calculations first, which, in itself may take a very long time to complete. Then comes the deletion part, even if you choose to delete the folders permanently (force delete).
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 (of size greater than 10 GB, for instance) from your hard disk using Explorer on Windows devices.
Delete Large Folders in Windows Quickly Using CMD
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 the 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 the use of the command line. Matt suggested adding the commands to the Explorer context menu so that users could run them in Explorer directly. This makes it both faster and easier.
The two commands that users require are Del, for deleting files, and Rmdir, for removing directories.
Here’s the step-by-step process to delete large folders using CMD:
- Tap on the Windows-key, type cmd.exe and select the result to load the command prompt.
- 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.
- The command DEL /F/Q/S *.* > NUL deletes all files in that folder structure, and omits the output which improves the process further.
- Use cd.. to navigate to the parent folder afterwards.
- Run the command RMDIR /Q/S foldername to delete the folder and all of its subfolders.
Here are descriptions of each of the commands used above.
DEL /F/Q/S *.* > NUL
- /F -- forces the deletion of read-only files.
- /Q -- enables quiet mode. You are not asked if it is ok to delete files (if you don't use this, you are asked for any file in the folder, which can be time-consuming and therefore counter-productive).
- /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.
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
Method #2: Creating a Batch File for Quick Deletion
If you don't need to run the command often, you may be perfectly fine running the commands directly from the command prompt.
However, if you do use it frequently, 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. This saves even more time without depending on a third-party software.
For this, the 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. You can do this by selecting Save as type as All Files.
The batch file comes with a security prompt. This provides you with an option 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-environment variable. While you may create your own variable, you may also move it to a folder that is already supported; e.g.: C:\Windows. In other words, you need to place this .bat file in C:\Windows so that the Windows registry can easily access it.
Do the following to add the new batch file to delete folders quickly to the Windows Explorer context menu. This can be executed in all major versions of Windows including Windows XP, Windows 7, and Windows 10.
- Tap on the Windows key, type regedit.exe, and tap in the Enter key to open the Windows Registry Editor.
- Confirm the UAC prompt.
- Go to HKEY_CLASSES_ROOT\Directory\shell\
- Right-click on Shell and select New > Key.
- Name the key Fast Delete
- Right-click on Fast Delete, and select New > Key.
- Name the key command.
- Double-click on default of the command key.
- Add cmd /c "cd %1 && delete.bat" as the value.
If you want to speed up the deletion process even further, you can always check some third-party tool like byenow.
how to restore back file if i accidentally delete file using bat
it couldn´t delete 2 ISO files i have downloaded,, my win 10 says that the files are open in system and can´t be deleted…
so how do i go by and create a bat file that deletes the directory before win10 loads up fully?…
yeah that fast delete shortcut in the menu seems risky lol
This looks like a great thing to add to a scammers startup programs
This batch file is very dangerous ! Need to be noticed on. My luck that I have tried it on draft area. It’s removing all files inside the folder without undo options/
this trashed all my documents including work files. I almost got fired. it also deleted my program that i was about to release to the public. Bot. It is a batch file that has gui , it talks , it runs , it lets you play solitare , and searches google. It took 2 years to finish the project that your program deleted. —–
Once you ve completed the steps, you can right-click a folder and select the Quick Delete option to remove a large folder super fast.
DO NOT PERFORM THIS METHOD
unless you have made a backup for the whole windows files,
I found that this registry shell method deleted my system files, now my windows is DOWN
just don’t create the .bat for creating the Windows Explorer Context Menu.
Define the (Default) value as: cmd /c “pause && del /s/q/f %1 > nul && rmdir /q/s %1″
Or save text below line as fast_delete.reg on desktop and double click it.
————
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Directory\shell\Fast Delete\command]
@=”cmd /c \”pause && del /s/q/f %1 > nul && rmdir /q/s %1\””
Thanks. :-)
Hello 2019!
Anybody else came here just to delete node_modules folder?
:D :D Me too!!!
Touche
Be sure to keep the delete prompt in the batch file, and ACTUALLY PAY ATTENTION TO THE MESSAGE before deleting. It seems that attempting to “Fast Delete” things from the Quick Access area of a Windows Explorer menu will result in a message of “Delete Folder: C:\Windows\system32?”
Easy way to ruin one’s day!
Clarification – it’s not the Quick Access I was referring to, but rather when you drill down through the file system on the left side.
How delete ready-only files? tried your script but get “access denied”
Thanks so much this really helped me
what about long file names.
What do you mean?
I succeeded I think in an easier way : Just create a new registry key to right click and delete. It will not prompt for confirmation though
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Directory\shell\Fast_delete\command]
@=”cmd /c \”cd \”%1\” && DEL /F/Q/S \”%1\” > NUL && RMDIR /Q/S \”%1\”\””
the regedit thing doesnt work for me. it says “system cannot find the specified path”
Did you add the batch file to a location in PATH? It won’t get picked up otherwise.
So I spiced this up a bit.
First by making a VERY clear warning and using a double confirmation before starting the procedure.
My delete.bat looks like this:
@ECHO OFF
ECHO _,.—–.,_
ECHO ,-~ ~-. +———————+
ECHO ,v___ ___v. + !!! WARNING !!! +
ECHO /~” ~” . “~ “~\ +———————+
ECHO 1 ,–.__ I __.–. 1
ECHO 1 Y ~-. 1 ,-~ Y 1 Really quick-delete Folder: “%CD%”?
ECHO 1 O }:{ O 1
ECHO j l / 1 \ ! l ALL FILES INVOLVED ARE LOST!
ECHO .-~ (___,.–” .v. “–.,___)~-. THIS PROCEDURE CANNOT BE UNDONE!
ECHO ( / / 1 \ \ ) DELETED FILES CANNOT BE RESTORED!
ECHO \.____, ~ \/”\/ ~ .____,/ NO PAPERBIN INVOLVED!
ECHO .____ ____.
ECHO 1 1T ~\ ! ! /~ T1 1 BE PATIENT WHILE DELETING!
ECHO 1 1l _ ___ _ !1 1 DELETE PROCEDURE WILL NOT PROMPT
ECHO 1 l\/V VVV V V\/ j 1 TO COMMAND SCREEN UNTIL FINISHED!
ECHO \ \1_1_1_1_1_1/ / /
ECHO \ [T T T T T TI /
ECHO 1 `v-v-v-v-v’ 1
ECHO \. ,/
ECHO “^-.__,-^”
ECHO.
ECHO.
ECHO PRESS “STRG-C” to ABORT procedure or CONFIRM by pressing any key twice…
ECHO =========================================================================
PAUSE
PAUSE
SET FOLDER=%CD%
CD /
DEL /F/Q/S “%FOLDER%” > NUL
RMDIR /Q/S “%FOLDER%”
ECHO.
ECHO =========================================================================
ECHO Folder: “%FOLDER%” SUCCESSFULLY DELETED! GLHF…
ECHO =========================================================================
ECHO.
ECHO.
ECHO +===================================================+
ECHO + FAST-DELETE BATCH proudly presented by L0eNNe555 +
ECHO +===================================================+
ECHO + PRESS ANY KEY TO EXIT +
ECHO +===================================================+
ECHO.
ECHO.
PAUSE
EXIT
Second, as Shawn correctly stated, I altered the registry CD command by adding the /d modifyer, so the command also safely changes harddrives in case you are deleting a folder on any drive other than C.
Looks like this:
cmd /c “cd /d %1 && delete.bat”
Thank you all for guidance and inspiration!
try the rdpro please https://github.com/mhisoft/rdpro
Rapid Delete Pro- recursively delete files and directories for Window, MacOS, Linux/Unix .
a free , open source
Wow! Works at the spped of light!
You can also use robocopy:
https://www.sysadmit.com/2015/08/windows-borrar-rutas-largas.html
With robocopy, you can also delete too long paths.
This will cause issues:
` cmd /c “cd %1 && delete.bat”
You should use pushd instead of cd, as it changes drive as well. Or use the /d switch of cd. Otherwise, it will purge the default directory (likely system32 or your user profile folder) if the directory you’re trying to purge isn’t on the C: drive.
` cmd /c “cd /d %1 && delete.bat”
This.
Created the batch file in W/10 64 bit but it would not let me place it in Program files, so i put it in the default documents folder, and did the rest as instructed (and restarted explorer.exe). But when i choose a folder to delete and hit Fast Delete in the R. click ,menu, then the command prompt flashes into view for a second but nothing happens.
So i installed unlocker http://www.majorgeeks.com/files/details/iobit_unlocker.html and which provides a Delete option and which worked quickly. Thank God for those who make such helps. I send some feedback to MS on this also:
If you choose a folder to be deleted, such as a 2GB folder in the C drive on a SSD hard drive, then it takes over 7 minutes just to calculate it. Even with a 4.2 Ghz 4-core CPU. You need a fast delete right click option.
Just noticed my Vivaldi JumpListIcons folder has inside it, in one folder, 600k files. On a slow laptop 5400rpm HDD seems pretty impossible to delete with more conventional ways. First letting windows try and calculate how many files are actually inside the folder and afterwards will give this method a try.
Googled for a better way and ended up here, should’ve known ghacks to be on it!
Still on track to taking about 13h or so for me even with this :<
The answer https://superuser.com/a/306618 to https://superuser.com/questions/167076/how-can-i-delete-a-symbolic-link warns:
“Be very careful. If you have a symbolic link that is a directory (made with mklink /d) then using DEL will delete all of the files in the target directory (the directory that the link points to), rather than just the link.
Solution: RMDIR on the other hand will only delete the directory link, not what the link points to.”
Same for me, Win 10 x64 Pro
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.
Same :/
Brilliant, thank you for the tip.
How about using shift+delete @martin? Is super fast for me…..
It should not be super fast if the folder is huge (meaning lots of files and folders inside).
keeping backups in archives =?
RD should’t be used since it’s slower.
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.
No, shift DEL still does the pointless calculation.
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
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
Is it possible to make the same file, using byenow to delete stuff?
Thanks in advance.
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…
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 . . . .
Linux has read-only NTFS abilities, so no, you cannot delete files off of an NTFS volume via a linux distro. This article is specifically for Windows, what did you expect? Why would you want to add another piece of software into the mix? This is the cleanest and fastest way to do it. Seems like you’re just finding things to complain about rather than just appreciating what the author has done to write about this.
Be more positive!
Not correct; there has been a read-write capable driver usable in Linux for over a decade now. It probably won’t be faster than file deleting in Windows though, because it’s a user-mode driver via FUSE.
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/
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.
System image is often single file:)
Yes. One file 45GB takes few seconds, 5000 files 1 GB a few minutes.
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.
Thanks for the useful article. I enjoy going back to 1985 DOS techniques to get something efficiently accomplished.
@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.
Gracias! Muy amable. Funciono perfectamente.
Thanks man!!!
ðŸ‘ðŸ‘ðŸ‘
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.
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?
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.
“There is no magic which makes you OS 20% faster because different file system”
oh my, are you mistaken…
There are massive performance differences (and stability, and reliability, and so on) between filesystems.
i.e. increasing the NTFS journal size has at times brought quite the beautiful impact on performance.
very small file performance between jfs2 and ext4 is… 1000s of times better.
ext4 on md raid outperforms everything else on ssds with fgpa/asic based compute offload.
while normal ext4 … does not.
ReFS is usually slower, except when it isn’t (vm storage)
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
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.
Great! Thank you! :)
Try deleting using PerigeeCopy’s Delete function? How fast is it?
perigeedelete doesn’t really seem all that great with many (hundreds of thousands) of files at all. the command line delete is super slow too if you have a (literally)million files.
gah, it seems it would be faster to copy all the other files from a tb drive to somewhere and format the disk and copy the files back..
Why not try it and report back.