Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I need to delete a large directory on one of our Windows 2003 servers containing around 1TB of data. Would the quickest way to delete this be to use cmd > rmdir?

share|improve this question
    
See also the following questions on StackOverflow and SuperUser: What's the fastest way to delete a large folder in Windows?, Mass deleting files in Windows. –  Heinzi Jan 17 '12 at 12:28
add comment

4 Answers

up vote 8 down vote accepted

Really, the fastest way I've discovered to do it has been, "rmdir /s [directory]". It seems to involve a LOT less meta-data operations than a, "del ." does, which makes it very zippy. I use it regularly to remove home directories with many thousands of files. Absolutely way faster than a remove-directory from Explorer, which seems to feel the need to count all the files before removing.

I haven't gone up to 1TB yet. If that 1TB involves less than, say, 10K files the big metadata operations would be marking vast swaths of space as free in the MFT. If that 1TB involves millions of files, then the metadata operations start to really slow things down on a file-by-file level. In that case, rmdir /s beats the pants off of Explorer.

share|improve this answer
    
Cool! Learn something new every day! Thanks! –  JFV May 19 '09 at 16:31
    
still brought our server to its knees, when deleting a folder with 24k files using rmdir /q /s {folder} .. –  Jeff Atwood Aug 4 '09 at 5:35
add comment

As sysadmin said, deleting individual files has massive overhead, so delete the folder. Regardless of the delete method you use, if you're going to delete a large number of files and/or folders it's worth temporarily disabling the AV software first. As a delete operation is both a read and a write the AV software is going to kick in and really slow things down, assuming of course you are running a real-time scanner.

share|improve this answer
add comment

I guess

rd /S /Q FolderToDelete

is the fastest option you have.

Warning: /S deletes all files and folders (tree) and /Q is the switch for "don't ask for confirmation."

share|improve this answer
add comment

Can I ask what you are trying to achieve ?

Unless you need the space back as quickly as possible then maybe the right method is to move the directory to a different location and spawn a thread that deletes files and directories slowly. This way the directory is not in the way and the server is not brought to its knees.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.