Click here to Skip to main content
15,946,316 members
Articles / Artificial Intelligence / Big Data
Tip/Trick

How to Delete a Large Folder in Windows

Rate me:
Please Sign up or sign in to vote.
5.00/5 (11 votes)
26 Apr 2015CPOL1 min read 22.6K   18   7
Explains the benefits of using the command line in the large folder delete case and shows an example of the syntax

Introduction

This is a really simple tip, but it is fairly useful if you overlook it.

So, our question today is: how to delete a folder containing zillions of files and sub folders?

Well, dah, I right-click on the folder in the Windows Explorer and select "Delete"? What kind of a silly question is that, even my 2 year old daughter randomly deletes folders from my computer when I am not looking.

Background

"Experts" might mumble, "egghh, use Shift-Del to permanently delete them, it's got to be faster since it bypasses the Recycle Bin". Well ... that is true but not the right answer.

The problem with using the Windows Explorer is that it checks the content of the folder before the delete action starts. It takes its time.

Solution

It turns out that using the Delete and even the Permanent Delete option is significantly slower than using the good old command line.

Another advantage is that it will not explode in your face as the Windows Explorer might when you push it too hard.

Ok, how to then?

The basic command is: rmdir, which can be used like this:

rmdir /s/q E:\StuffToDelete\HugeFolder

However, that is a significant improvement when the subfolders` structure is also large. In such a case, you can get almost three times better performance using del before the rmdir.

The del command will delete only the files and the rmdir will handle the empty folders afterwards. E.g.:

del /f/s/q E:\StuffToDelete\HugeFolder > nul
rmdir /s/q E:\StuffToDelete\HugeFolder

NOTE: Do not make performance tests in parallel, since Windows will prioritize the Windows Explorer process over the rmdir batch process and it will thus seem to be slower (in fact, it may even freeze until the shift-del process will finalize).

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Chief Technology Officer
United States United States
Senior dish washing consultant for over 25 years!

Comments and Discussions

 
GeneralThoughts Pin
PIEBALDconsult27-Apr-15 7:19
mvePIEBALDconsult27-Apr-15 7:19 
GeneralRe: Thoughts Pin
Joezer BH27-Apr-15 19:53
professionalJoezer BH27-Apr-15 19:53 
QuestionI would need some proof... Pin
Alexandru Lungu27-Apr-15 5:33
professionalAlexandru Lungu27-Apr-15 5:33 
AnswerRe: I would need some proof... Pin
Joezer BH27-Apr-15 19:57
professionalJoezer BH27-Apr-15 19:57 
QuestionYou want to see what happens when you use webdav Pin
Dr Gadgit27-Apr-15 4:09
Dr Gadgit27-Apr-15 4:09 
QuestionNice Pin
phil.o27-Apr-15 1:08
professionalphil.o27-Apr-15 1:08 
AnswerRe: Nice Pin
Joezer BH27-Apr-15 2:17
professionalJoezer BH27-Apr-15 2:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.