Previous 1 2 3 Next 34 Replies Latest reply: Jun 9, 2009 8:21 PM by cornelius
TMega Level 1 Level 1 (0 points)
When throwing out, say 250000 items, it can take a LONG time. First you wait for the "Preparing to empty the Trash..." and then you suffer through "Emptying the Trash..." My question is, "Is there a quick way to do this?", and if not "Why not?"

Years ago there was the ability to hold down something like the option & command keys while emptying the trash, and it emptied very quickly, but either I've forgotten the key combination, or it's just not allowed anymore.

Having a quick way to empty trash would be very helpful when performing operations such as,
1) clearing an external drive of most (but not all) data
2) removing a very large iPhoto library (or libraries)
etc...

Although I've searched dilegently for an answer to this, all I've found are suggestions to us the "erase" command in Disk Utility or the rm command in terminal. The erase command is useless if you want to keep files on the disk, and the rm command doesn't seem to provide a speed improvement, at least in my hands.

Thanks

17" MacBook Pro 2.4GHz, 4GB, 160GB, Mac OS X (10.5.6), Time Machine
  • planb77 Level 7 Level 7 (32,290 points)
    Hey there,
    Will cmd-option-shift-Backspace do the job? This option empty the trash (including all locked files and such) without any sort of warning dialog. Just giving it a shot. Hope it helps.

    B-rock
  • TMega Level 1 Level 1 (0 points)
    I have tried that, and it does not seem to help since the "Emptying the Trash..." step still persists, counting down the items. However, I must admit that I have not done real testing of one method verses another since I usually just wait it out with the slow methods I know, and of course, once something is trashed, why would I trash the identical thing?

    But I did just try your method with a fairly large amount, and as I said, the "Emptying the Trash..." step was definitely significant.

    I would think that a method that truly works will be real obvious: issue command, bam, it's done, but perhaps that assumption is wrong.
  • Scott Radloff Level 6 Level 6 (14,490 points)
    TMega,

    What you want is really not possible. Removing so many files at once is a terribly complex operation, complicated by the need for journaling and updating of the FS_Events Database. Each modern/advanced feature of the HFS+ file system adds its own little bit of overhead to the process.

    You wouldn't want it any other way, in truth.

    All this said, there's no reason why you have to wait for these operations to complete before moving on to something else. This is one of the major reasons why the Finder is now multi-threaded; so that you can issue the commend to move files or empty the trash, and carry on immediately to other things, even within the Finder. Can you not do this?

    Scott
  • TMega Level 1 Level 1 (0 points)
    Scott,

    Performing other tasks can be quite slow, even though I have a Core Duo 2.4GHz with 4GB ram, during a major delete.

    I don't see why there cannot be a quick way to do a major delete operation since, after all, this in effect happens when you use the "erase" operation of the Disk Utility, which happens almost instantly.

    For example, the "quick delete" option that I am suggesting could be a routine which checks the locations of the files which are NOT to be deleted, preserve that portion of the disk, and then perform the "erase" command mentioned above, for the rest of the disk.

    Clever software folks like those at Apple certainly could solve this problem if someone like me can. The problem I think, is that there have not been enough complaining about this issue. If it were solved, maintaining hard drives which contain large numbers of files (such as backups, iPhoto libraries, web sites, etc...) would become quick and easy rather than so darn slow that you have to come back hours later and remember what you were doing.
  • varjak paw Level 10 Level 10 (169,830 points)
    I don't see why there cannot be a quick way to do a major delete operation since, after all, this in effect happens when you use the "erase" operation of the Disk Utility, which happens almost instantly.

    No, not really. An Erase just in essence deletes all the entries in the disk catalog, something that can be done quite quickly. Deleting specific files from a drive requires much more activity in the OS to properly update all the records, so it takes longer. Creating a "hybrid" sort of deletion might be possible - I'm no file system engineer to know for sure - but would almost certainly require a major re-engineering of the Mac file system (HFS+). But reliability is essential, so any sort of function to erase a file that might pose a risk to the integrity of the remaining data must be avoided; I'll trade off a bit of performance in favor of protecting my data any day of the week.

    Apple appears to be moving toward ZFS as a supported file system for large volumes on Macs (eventually it may replace HFS+ as the primary file system for Mac OS X, though that's not certain at this point) which may improve matters, but any file system with high reliability is going to go through a number of steps to delete a file, so deletion of large numbers of files is never going to be a speedy process.

    Regards.
  • Scott Radloff Level 6 Level 6 (14,490 points)
    TMega,

    Um, do you by any chance have "Secure empty trash" selected in the "Advanced" pane of your Finder preferences???

    Scott
  • TMega Level 1 Level 1 (0 points)
    Nope, secure empty is not checked in Finder preferences.

    Thank you for your explanation. I guess I'll just have to keep waiting hours for the trash to empty when doing major deletes.

    Sigh.

    I suppose a work around could be to copy OTHER items to another temp location and then use the "erase" feature. In my opinion, using work arounds usually means software hasn't been developed quite as nicely as it could be...
  • nerowolfe Level 6 Level 6 (13,070 points)
    TMega wrote:
    Nope, secure empty is not checked in Finder preferences.

    Thank you for your explanation. I guess I'll just have to keep waiting hours for the trash to empty when doing major deletes.

    Sigh.

    I suppose a work around could be to copy OTHER items to another temp location and then use the "erase" feature. In my opinion, using work arounds usually means software hasn't been developed quite as nicely as it could be...


    You can use the terminal and zap them instantly.
  • KLQ727 Level 1 Level 1 (0 points)
    I have the same issue...how do you use the terminal to do this? I'm fairly new to MAC so need some details please.
    Thanks in advance!!! I have over 357k items to delete and it estimates 4111 hours to do this!
  • cornelius Level 6 Level 6 (17,825 points)
    Is there a reason why you save so many files in the Trash? It would be a lot easier both to know what is in Trash and to empty Trash if you did it more regularly. Not to mention the disk capacity becoming available from emptied Trash.

    cornelius
  • dechamp Level 4 Level 4 (3,495 points)
    With a journaled file system, spotlight considerations, and the safety of a Time Machine backup, keeping hundreds of thousands of files in the trash is very rare. I wouldn't think that Apple would waste the time to engineer a specific feature in the OS for something that shouldn't happen in the first place.

    They did engineer an excellent way to recover files that have been deleted.
  • nerowolfe Level 6 Level 6 (13,070 points)
    dechamp wrote:
    With a journaled file system, spotlight considerations, and the safety of a Time Machine backup, keeping hundreds of thousands of files in the trash is very rare. I wouldn't think that Apple would waste the time to engineer a specific feature in the OS for something that shouldn't happen in the first place.

    They did engineer an excellent way to recover files that have been deleted.

    I agree. My trash is essentially always empty. It's not a special storage place, it's the trash bin.
    And I don't understand why using
    rm
    in a terminal is slow, as the OP said.
    It's practically instantaneous.
    In fact, one could keep a FakeTrash directory on the desktop for the files that are to be stored as "trash" for whatever reason, and then zap that directory in one fell swoop anytime one wished.
    Keeping files in the trash for more than one session is never a good idea, IMO. Besides after a while the trash starts to smell
  • BobHarris Level 6 Level 6 (15,375 points)
    I have over 357k items to delete and it estimates 4111 hours to do this!

    Do you have Secure Erase enabled? Otherwise it should NOT take 171 days to delete your trash.

    If you really want to use the Terminal, then since you are both new the Mac and most likely new to Unix, I hope you have a backup, because what I'm about to tell you is walking a tightrope without a safety net with one eye closed.

    Applications -> Utilities -> Terminal

    cd .Trash # change current working directory
    pwd # display current working directory

    The "pwd" should say something like "/Users/yourusername/.Trash". If it DOES NOT, then STOP!

    If the "pwd" command is correct, then you can try to delete the items in the trash:

    rm -rf * # this is the dangerous command!

    The "rm -rf *" will delete everything in the current working directory and ALL subdirectories below. If you execute this command from the wrong location you will destroy valuable files, so make sure you are positive you are where you are suppose to be when you issue the "rm" command, because there is NO RECOVERY FROM THIS COMMAND!
  • KJK555 Level 4 Level 4 (2,895 points)
    open terminal.app
    at the prompt type in the following command:
    sudo mv ~/.Trash ~/Desktop/Trash
    (press return, enter admin password, press return again.)

    Logout, then log back in (a new ~/.Trash file will be created).
    Your trash can will now be empty and all your old trash files will
    be on your desktop in the new "Trash" folder.

    Make another folder on your desktop, call it "rsync".
    drag and drop a small file in the rsync folder (any file will do).

    Open terminal, at the prompt:
    sudo rsync -av --delete ~/Desktop/rsync/ ~/Desktop/Trash

    rsync is one of the few terminal commands that has been optimized for speed.
    It's like cp and/or rm on steroids.
    It can copy and delete files faster than any other terminal command.
    In the above example I "tricked" rsync into synchronizing the contents of the
    "Trash" folder with the contents of the "rsync" folder (which held only a single file).
    rsync deleted all files in the "Trash" folder and added the one file from the "rsync" folder.

    I added about 7GB to my Trash folder before running rsync. It deleted those 7GB of files
    in a little more than 1 minute. They were all small files copied from my system directories.
    Your mileage may vary, I am running a Mac Pro with a WD VelociRaptor boot drive.
    I was also running rsync in verbose mode which will actually slow it down a bit
    (but it is fun watching the filenames fly across the screen).

    be sure to familiarize yourself with rsync's syntax before using it. It is not difficult, but it is
    slightly different than rm, cp, etc. The manual explains it pretty well. The syntax in
    the command I posted is correct for the example I discussed.
    In particular pay attention to the "trailing slash" on the source to avoid creating
    an additional directory level at the destination (discussed in the manual).

    Be aware of course that rsync does NOT secure delete files.

    Kj
Previous 1 2 3 Next