Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I frequently connect different external USB hard drives and flash drives to my computer and I would like to facilitate deleting files and regaining disk space from them.

If I simply delete the file, it will be kept in a hidden trash folder on the external drive until I empty the Trash. This also forces me to empty my local trash simultaneously while the external disk is still connected to regain the disk space, which is undesirable.

At the moment, the only other "solution" I've found is moving the file to the internal hard drive and then trash it. This is not optimal because I waste time moving files from one drive to another (I regularly deal with 20GB+ VMs).

How can I permanently delete a file from an external drive, bypassing the trash?

share|improve this question
1  
It is very difficult to erase permanently something from a flash based USB drive. Further reading: security.stackexchange.com/questions/5662/… –  Andris Oct 5 '12 at 10:39
1  
@Andris Thanks, interesting link. I think I framed my question badly. I'm not interested in a secure deletion. I'm simply interested in deleting a file and regaining the space. –  Redandwhite Oct 5 '12 at 10:54
    
So, you can't empty trash locally when the file is external, but you can when it's stored internally? Why on earth keep anything in trash anywhere when you are one step away from deleting it? I don't get the justification added. Why not edit that out and just say you want to do X? –  bmike Oct 8 '12 at 18:45
4  
@bmike because I don't mind having a trash locally. I DO mind having a trash on a more limited flash drive. Essentially, deleting a file does not free up space on the drive. I know this is the same for local disks, but it's more acceptable to me. This addresses a specific use case. –  Redandwhite Oct 8 '12 at 21:32

6 Answers 6

up vote 30 down vote accepted

You can create an Automator service or application to facilitate executing the rm shell commando, which will permanently delete files or folders and skip the trash.

For example, start with creating a new Service in Automator.app.

  • Select files or folders as input, you probably also want to limit the availability of this service to the Finder app.

Automator service input

  • Optionally, but highly recommended, first add an Ask for Confirmation step to the workflow.

Confirmation step

  • Finally, add the Run Shell Script step to the workflow. Make sure to pass input as arguments. Then you can put in the following script:

    for f in "$@"
    do
        rm -rf "$f"
    done
    

Input shell script

As mentioned by @Thecafremo, you can also add a -P parameter to rm for additional security while deleting. For an extra nicety, you can add some audible feedback by adding the following command at the end of the shell script:

afplay "/System/Library/Components/CoreAudio.component/Contents/SharedSupport/SystemSounds/finder/empty trash.aif"

Save your service, and it should be ready to use in Finder from the Services menu in the menu bar. You can also configure a keyboard shortcut to your service in the Keyboard preference pane of System Preferences.

Services menu

Service in action

Instead of creating a service, you could similarly create an application in Automator, which you can pin in the Dock so you can drag files to it.

share|improve this answer
1  
This is for sure the most elegant solution. And it's free :-) –  Maverik Oct 5 '12 at 8:51
    
This is really nice. Thanks for a great solution :) –  Redandwhite Oct 5 '12 at 19:25
    
This isn't working for me in Mavericks... It just doesn't do anything when I use the service. –  Bruno Stonek Feb 16 at 18:36
    
Great answer, but consider improving it by making it prompt for password if and when superuser privilege is necessary for a deletion. –  Terry N Apr 3 at 12:33

There is a free tool called Skip The Trash, which not only allows regular deletion, but authenticated deletion as an admin. It adds context menus to the Finder:

http://www.blazingtools.com/delete_without_trash_mac.html

share|improve this answer

How about something like Trash X. The description says:

You can use it to instantly delete or shred file and folders without sending them to the trash. You can use it to empty or shred trash only on selected disks. And of course, you can use it just like the trashcan you've always had on your desktop.

share|improve this answer

Background information can be found in the paper Secure Deletion of Data from Magnetic and Solid-State Memory

An implementation of the knowledge gained from this paper is GNU shred. This tool can be installed as part of coreutils from MacPorts.

share|improve this answer
    
Why the downvote? Who doesn't like MacPorts or GNU tools? –  user18805 Oct 5 '12 at 8:31
    
I wasn't the person to down vote, but I don't feel that this answers the question. Perhaps the original is worded badly –  Redandwhite Oct 5 '12 at 19:07

Have you consider to use Trash Without from the Mac App Store?

share|improve this answer
1  
This looks decent, but I was wondering if there's anything freely available. –  Redandwhite Oct 5 '12 at 7:39
    
That's true :-) But at least it is cheap. –  Maverik Oct 5 '12 at 8:14

And option could be Terminal command rm, with the -P option if you want some added security:

[Option -P will] Overwrite regular files before deleting them. Files are overwritten three times, first with the byte pattern 0xff, then 0x00, and then 0xff again, before they are deleted.

To do so, just:

  1. Open the Terminal.app (Found in /Applications/Utilities).
  2. Type rm -P and drag the file to the terminal window. Then hit Enter.
share|improve this answer
1  
Woah, dragging the folder will delete the whole folder, right? –  duci9y Oct 5 '12 at 7:33
1  
@duci9y Right! I'll edit the answer to correct it. Answering without proofreading is not the best thing to do, indeed. –  Thecafremo Oct 5 '12 at 7:34
1  
You can also remove a folder if you use the option -rf. –  Maverik Oct 5 '12 at 8:33

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.