What's the fastest way to delete a large folder in Windows?
I want to delete a folder that contains thousands of files and folders. If I use Windows Explorer to delete the folder it can take 10-15 minutes (not always, but often). Is there a faster way in Windows to delete folders?
Other details:
- I don't care about the recycle bin.
- It's an NTFS drive.
The worst way is to send to Recycle Bin: you still need to delete them. Next worst is shift+delete with Windows Explorer: it wastes loads of time checking the contents before starting deleting anything.
Next best is to use rmdir /s/q foldername
from the command line. del /f/s/q foldername
is good too, but it leaves behind the directory structure.
The best I've found is a two line batch file with a first pass to delete files and outputs to nul to avoid the overhead of writing to screen for every singe file. A second pass then cleans up the remaining directory structure:
del /f/s/q foldername > nul
rmdir /s/q foldername
This is nearly three times faster than a single rmdir, based on time tests with a Windows XP encrypted disk, deleting ~30GB/1,000,000 files/15,000 folders: rmdir
takes ~2.5 hours, del+rmdir
takes ~53 minutes. More info at Super User.
This is a regular task for me, so I usually move the stuff I need to delete to C:\stufftodelete and have those del+rmdir
commands in a deletestuff.bat batch file. This is scheduled to run at night, but sometimes I need to run it during the day so the quicker the better.
Technet documentation for del
command can be found here. Additional info on the parameters used above:
-
/f
- Force (i.e. delete files even if they're read only) -
/s
- Recursive / Include Subfolders (this definition from SS64, as technet simply states "specified files", which isn't helpful). -
/q
- Quiet (i.e. do not prompt user for confirmation)
Documentation for rmdir
here. Parameters are:
-
/s
- Recursive (i.e. same as del's /s parameter) -
/q
- Quiet (i.e. same as del's /q parameter)
Using Windows Command Prompt:
rmdir /s /q folder
Using Powershell:
powershell -Command "Remove-Item -LiteralPath 'folder' -Force -Recurse"
Note that in more cases del
and rmdir
wil leave you with leftover files, where Powershell manages to delete the files.