6.3 Million Too Many Files to Delete?

I tried to split a large movie file to transfer on a Fat 32 formatted external hard drive, and I accidentally created 6.3 Million Files in my Movies folder, and now Finder freezes when I try to delete them. Help please! My Mac Pro is running really sluggish from all the fragmenting, but I dont want to defrag until I delete this crap off here.

Mac Pro, Mac OS X (10.6.8)

Posted on May 18, 2012 10:05 PM

Reply
11 replies

May 18, 2012 11:18 PM in response to penguinlove777

It's probably running slow because the finder is choking on all those files in a single directory not bacause of the file system.


I'm thinking out loud here...


You pretty much have a bad problem that won't be easy to fix. Even if you could creep along in the finder to to get those files into the trash that would take forever to erase.


The fastest way to delete is to not use the finder but delete from the terminal instead but even doing it this way will take a long long time if it works at all. And there's the problem of trying to reference these names from the terminal command line. You could remove the entire Movies file to get around the naming problem but I don't know what other stuff in the Movies folder that may take with it. And it still would take a very long time if it worked at all (I think -- does a rm -rf of a directory have to remove all the files in the directory first? -- never had a directory so large as to ever ask that question).


The only real solution I see is revert to your backup. You have one right?


Alternatively make another user and migrate what you can from the "old" account and leave the old account in place taking up all that file space. I suspect deleting the old account will end up again taking a very long time also.

May 18, 2012 11:25 PM in response to penguinlove777

It doesn't matter what you use. 6.3 million files is going to take, like, forever.


The most basic way to delete, as I said is to use the terminal. And any utility you could possibly download cannot do it faster than that. If you are willing to gamble and loose the entire Movies folder here is what you do.


1. Make a bootable backup of what you currently have using a backup utility like Carbon Copy Cloner. This is just in case step 2 ends is failure.


2. Open terminal (in Utilities). Type rm -rf followed by a space. The drag the Movies folder into the terminal window. You should have a line that looks something like:


rm -rf /path/to/Movies


Hit return.


3. Go on vacation somewhere. Or at least sleep on it. 😉

May 18, 2012 11:35 PM in response to penguinlove777

In Terminal, paste this command


sudo rm -rf ~/Movies/*.*


Type your password when asked, but type carefully as it will be invisible.


This should delete all the files ( not any folder) in the Movie folder instantaneously (it won't move them to Trash).


If you have any folders in there, after this command you should be able to go into the Movie folder in Finder, click on any Folder ONCE and hit 'Command - Delete' on the keyboard to send it to Trash.

May 18, 2012 11:38 PM in response to penguinlove777

More thinking out loud of another possibility...


Using CCC there may be a way out of this.


1. Make a bootable backup but edit what CCC is to backup by not including your Movies directory as an item to be backed up. You can do this with CCC because it lists the stuff to copy with checkboxes to disable copying of items by unchecking the item's checkbox.


At this point you have a bootable backup which is identical to your original boot disk minus the Movies directory in your home directory.


2. Boot from the backup to make sure it works because step 3 is going to "cut the cord" and your only boot disk will be that backup. If it were me I would make two backups just to be extra safe.


3. Erase you original disk with Disk Utility. That's fast.


4. Use CCC to copy the bootable clone (which doesn't have your Movies) back to the disk you erased in step 3.


Backups with CCC are pretty fast, albeit that first time will take a while but not forever. Disk Utility erases are very fast too. So this idea may be a faster way then deleting all those files in Movies. Also what "fragmatation" concerns you may have are non-existant since CCC is coping files not doing a bit-for-bit clone operation.

May 18, 2012 11:38 PM in response to X423424X

I'd be interested to know who's right here, you or I (purely for the sake of knowledge, I'm not being competitive).


It seems to me that the sudo rm -rf ~/Movies*.* command should take no time at all. All its doing is telling the disk directory to ignore any files in the Movies folder. That shouldn't take any time at all.


Perhaps the OP could let us know how it goes.



🙂

May 18, 2012 11:48 PM in response to softwater

rm -rf ~/Movies*.* ???


I don't understand that. Or did you mean ~Movies/* ? That won't work with 6.3 million files. You would have to use xargs and that won't be any faster creating a monstrous arg list.


Or would that be the moral equivalent of rm -rf ~/Movies ? But that's what I mentioned above and wondered if it still has to go through the files within the directory before deleting the directory itself.


Update:

Oops, missed your earlier post. You did mean ~/Movies/*.* so you would need xargs since there is alimit to how many args a wild card can expand to on the bash command line. That's why xargs exists.

May 19, 2012 12:03 AM in response to X423424X

X423424X wrote:


You did mean ~/Movies/*.* so you would need xargs since there is alimit to how many args a wild card can expand to on the bash command line. That's why xargs exists.


My bad. Typo on the later mention of that.


Thanks for the tip about xargs; never tried it on anything that large so wasn't aware of the limit. Will have a look at the man page for xargs.


Cheers! 🙂

May 19, 2012 5:09 PM in response to softwater

In Terminal, paste this command


sudo rm -rf ~/Movies/*.*


Type your password when asked, but type carefully as it will be invisible.


This should delete all the files ( not any folder) in the Movie folder instantaneously (it won't move them to Trash).

Unfortunately, this won't work.


You might think it will, but it's a common misunderstanding


When you use this kind of command, the shell expands the '*.*' component into a list of matching files, and then passes the resulting list to the command (in this case, 'sudo rm -rf'). In other words, it's the shell that pre-processes the wildcard, not the command you're invoking - for the most part the command doesn't even know a wildcard was used.

The problem is that there is a limit on the length of any single command (typically 262,144 characters) and those 6.3 million files are going to exceed that limit - you'll get an error 'command too long' or some such.


That's why alternative options are needed.


Personally, I'd have used a find, rather than deleting the entire Movies directory, especially if there's some common filename component you can filter it by:


cd ~/Movies

find ~/Movies -name 'mymovie.*' --delete


Find will find end delete each file without running into the command line limit.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

6.3 Million Too Many Files to Delete?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.