How can I speed up the deleting of very large directories on XP?

9

0

I regularly check out incredibly huge directories onto my XP machine. When it comes down to deleting and finally trashing them, it takes forever. Is there any way to speed this process up?

Christek

Posted 2009-09-23T15:09:39.803

Reputation: 195

Are your partitions formatted as FAT32 or NTFS? You might want to try converting to NTFS if you're not already using it - some of the algorithms used on FAT32 (like the way it works out the 8.3 filename for each file) are poorly behaved (SLOW) on directories with 100s or 1000s of files. – Bevan – 2010-05-12T18:52:57.770

Duplicate of this? http://superuser.com/questions/19762/mass-deleting-files-in-windows/289399#289399

– Hugo – 2011-06-02T16:31:24.410

1For some reason every one of the answers thinks there's a problem with the recycle bin. Is that really even the problem? – random – 2009-09-23T15:24:08.853

I can off assumed since he mentioned deleting then trashing both parts were taking a long time, therefore skipping one part would help – Col – 2009-09-23T16:25:45.860

1...and it's usually quicker when you use the recycle bin. – pelms – 2009-09-23T16:28:23.967

Answers

8

I usually delete huge directories from the command line. It bypasses the Trash and is typically much faster. You should be careful and check the command you type twice, so as not to accidentally delete something really important.

The easiest way is to use rmdir:

rmdir /S /Q C:\My\Directory\Name

You need /Q to stop rmdir asking you if you're sure or not.

If some files are currently open by some process, they and the directories they contain naturally won't be deleted. There are tools that can help you understand which process locks the file, but it's a different story from this one.

piggymouse

Posted 2009-09-23T15:09:39.803

Reputation: 126

I've found that del /followed by rmdir (to tidy the directory structure left by del) is quicker than just rmdir: http://superuser.com/questions/45661/how-can-i-speed-up-the-deleting-of-very-large-directories-on-xp/292155#292155

– Hugo – 2011-06-05T18:44:06.990

5

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 here.

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.

Hugo

Posted 2009-09-23T15:09:39.803

Reputation: 2 640

4

Press SHIFT + DELETE to delete files/directories while skipping the recycle bin.

Note: You cannot recover these files, but it's faster!

th3dude

Posted 2009-09-23T15:09:39.803

Reputation: 9 189

Even then enumerating files is slower in explorer than by other means. So better use console methods for the real big numbers – Marco van de Voort – 2015-12-23T19:04:45.660

This is the easiest way, by far. Windows has had this feature since Windows 95 and its really useful. – djangofan – 2011-06-02T16:32:39.030

+1 I do the same thing. Much faster, but can sometimes cause headaches if you delete the wrong thing by mistake. – alex – 2009-10-09T11:35:01.893

2

If you want to bypass the recycle bin just hold down the shift key while deleting, also sometimes I find the command line del command to be quicker than deleting through explorer. If it's always the same folder you're deleting set up a batch file for it.

You could even schedule it to happen on a regular basis if that's suitable.

Col

Posted 2009-09-23T15:09:39.803

Reputation: 6 995

0

Here's a more off the wall suggestion if you're regularly doing this and the circumstances are right.

Store your directory in a separate disk partition. The benefit is that you can very quickly (almost instantly) destroy and recreate partitions.

There are obvious limitations such as having fixed partition sizes unless you use/trust something like Partition Magic. However, I have used this technique when dealing with very large SDKs which get updated frequently.

tonylo

Posted 2009-09-23T15:09:39.803

Reputation: 2 926

0

Maybe deactivating the trash can before you start could be helpful.

Martin

Posted 2009-09-23T15:09:39.803

Reputation: 3 619

0

I don't have a huge directory handy to test this out on, buy try using shift+delete to delete the files. This step skips the recycle bin, which ought to save you some time.

Ryan

Posted 2009-09-23T15:09:39.803

Reputation: 1 728

0

Keep your trash can close to empty. Putting items in a full trashcan takes much longer.

Windows will quickly move items into the trash until it fills up. After that it needs to delete the oldest items in the trash to make room for new items. This process is very slow.

Chris Nava

Posted 2009-09-23T15:09:39.803

Reputation: 7 009

0

FastCopy includes a delete option. I haven't tried it that much myself but it may a fast alternative.

Andreas

Posted 2009-09-23T15:09:39.803

Reputation: 257