Clear all

Deleting massive amounts of files quickly


Topic starter


This is just a quick tip.

I am recovering data from a drive that I stupidly began to zero out and as one might guess the recovery, although running smoothly because the drive was fine, is bringing up a lot of strange material that I can no longer work with. So I need to delete some of them.

So I will use my situation to give you one example of how to delete thousands of files really quickly, as in really quickly.

I had thousands of .ttf files, something like 250,000 .ttf files. It's a nightmare to delete that many files followed by an empty trash command using the Finder. It takes hours for the computer to go through that much material, process a move to trash followed by the empty trash command.

So in comes the terminal. One warning though, the command is destructive, meaning files processed this way can't be recovered from the trash.

First I navigate to the root folder where my recovered files are being moved to (from one drive to another)

To navigate use the cd command.

cd (leave a space after the cd and then drag and drop from the Finder into the Terminal window the folder you want the next command to work with)

Something like:

cd /Volumes/LaCie RAID 0 (Striped)/Recovered

Next I want to instruct the computer dig through every folder inside the Recovered folder, finding all files that end with .ttf and delete them.

find . -name '*.ttf' -delete

So the command as you can guess is find, the dot means the current directory. -name is obvious (file names) and then the '*.ttf' -delete simply targets and deletes any and all files ending with .ttf.

I can tell you that there were over 250,000 .ttf files recovered, it took one minute for the command to chew threw them all. The Finder is outrageously slow at this task.

For some perspective, I issued the command against a 4TB Lacie 2Big Quantum striped RAID (2x 2TB rotational drives) connected to the Mac via Firewire 800. Not the fastest setup by today's standards but while I issued the command the drive was actively recovering files and yet within about 1 minute it had deleted 250,000 files. This is not a testament of the device but rather how efficient terminal commands can be relative to the Finder. The Finder could not even come close to this kind of performance but MacOS can with a little help from the terminal.


You can learn more about the specific example command I mention above here:*.ttf%27+-delete

More on the find command itself here:

This topic was modified 2 years ago 6 times by Alex Santos
Topic Tags