71

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?

6
  • 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, 2012 at 10:39
  • 3
    @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. Oct 5, 2012 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, 2012 at 18:45
  • 7
    @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. Oct 8, 2012 at 21:32
  • It is incredible that Apple don't see what a problem this is. How on earth is a normal user supposed to understand what is going on? From their point of view their USB drive is empty but useless!
    – cja
    Mar 14, 2015 at 21:34

9 Answers 9

27

⌘ Command⌥ Option⌫ Delete will permanently delete files, with a confirmation dialog warning that this action can not be undone. ⌘Command⌫ Delete simply moves files to Trash, without confirmation.

Tip: whenever you want Mac app to do the same action but a little differently, try doing it with ⌥ Option button pressed.

1
  • 1
    Thanks! This is now the accepted answer. For the benefit of others, it might be helpful to note in your answer that Alt is called Option on US-layout keyboard. Jun 19, 2016 at 9:14
55

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. The service will also appear at the bottom of the menu you get by right clicking on files in Finder, although to make it appear there you may have to run it once from the Finder > Services menu first. 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.

8
  • 1
    This is for sure the most elegant solution. And it's free :-)
    – Maverik
    Oct 5, 2012 at 8:51
  • This is really nice. Thanks for a great solution :) Oct 5, 2012 at 19:25
  • This isn't working for me in Mavericks... It just doesn't do anything when I use the service. Feb 16, 2014 at 18:36
  • 1
    I would like to add that this service can even be used to delete files that are already in the trash--something that is otherwise very difficult. (Awesome!) Aug 16, 2014 at 12:30
  • 1
    Awesome! Couple of things. Clicking on the icon inside Ask for Confirmation step will change it to an yellow exclamation sign - handy to warn that what you're about to do is dangerous. When saving, the name entered should be "Permanently Delete" as this is what will be shown in the Services menu. Sadly this doesn't support sudo when password is required. I tried using osascript -e ... with administrator priveleges but escaping the original " with \" didn't seem to work.
    – ADTC
    Jul 12, 2015 at 8:57
21

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.
5
  • 1
    Woah, dragging the folder will delete the whole folder, right?
    – duci9y
    Oct 5, 2012 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, 2012 at 7:34
  • 2
    You can also remove a folder if you use the option -rf.
    – Maverik
    Oct 5, 2012 at 8:33
  • 1
    sudo rm -rf followed by space works wonders, thanks!
    – PatrickT
    Aug 28, 2014 at 15:24
  • 1
    The Accepted Solution above is good if you have to do this frequently, but I just had one file I needed to nuke (from orbit) and this does the trick.
    – hairboat
    Oct 27, 2014 at 22:33
4

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

2
  • 1
    This looks decent, but I was wondering if there's anything freely available. Oct 5, 2012 at 7:39
  • That's true :-) But at least it is cheap.
    – Maverik
    Oct 5, 2012 at 8:14
4

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.

4

The following trick works with OS X El Capitan. I got the tip from here.

Select your file(s) in Finder. Go to the File menu, and when you press the alt/option key, you will see the "Move to Trash" option change to "Delete Immediately...".

2

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.

2
  • Why the downvote? Who doesn't like MacPorts or GNU tools?
    – user18805
    Oct 5, 2012 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 Oct 5, 2012 at 19:07
2

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

0

As of El Capitan 10.11.6 this is now possible without using Terminal.app: select the files you want rid of, right click and pick "Delete Immediately…".

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .