Permanently deleting files on Mac OS

21

6

A while back, as relatively new Mac OS X user, I was surprised to learn that you cannot easily delete files. Directly, that is, without moving them to the trash first. On Windows and Linux this can obviously be done with ease, but not so on the Mac.

I noticed this when trying clear up files from a USB memory stick — removing the files ("move to trash") does not free up space; that happens only after emptying the whole system-wide Trash. Not particularly convenient! (It seems stupid to have to empty the whole trashcan just to make some space on the USB stick. There might be gigabytes of stuff in there, and this sort of defeats its purpose - what if you'd actually need to restore something from the trash some day.)

So, what's your way of getting around this? Have you bought a 3rd party application like RAW Trash for $16.95 just to delete files, or do you diligently empty the trashcan whenever needed? Or did I miss something? Also, can you convince me that this is actually the way it should be — that users shouldn't be able to fiddle with the filesystem easily? :)

Jonik

Posted 2009-07-22T09:44:10.200

Reputation: 5 352

1Were you looking for the shortcut ⌘+⌥+⌫ (Command+Option+Delete)? – Daniel – 2018-09-06T04:57:20.873

Answers

22

I'm not so happy with the way Mac OS X handles this either. If I really want to delete something, especially from USB memory sticks, I usually fire up Terminal and rm the files manually.

Daan

Posted 2009-07-22T09:44:10.200

Reputation: 590

28

Since so many people seem to want it, I just created a Service to do this, for Snow Leopard, called Delete Immediately. It shows up in the Services menu and the context menu in Finder.

You can download it from GitHub. Uncompress the .zip archive and move the resulting "Delete Immediately.service" to the Services folder in your library folder, ~/Library/Services/. You may need to log out and back in (and/or enable it in the Services section of the Keyboard preferences) for the system to recognize the service.

I'd also suggest checking out the README file on the main page on GitHub. And if you want to contribute to the code, localize it, or make an icon, feel free!

Context menu

Services menu

jtbandes

Posted 2009-07-22T09:44:10.200

Reputation: 8 350

Finally got round to testing this, and it indeed works smoothly! (So a big +1 from me too; I'll keep the rm method as accepted answer though, as installing 3rd party tools for this shouldn't be mandatory IMHO...) Your "Delete Immediately" might end up putting creators of RAW Trash out of business, you know. :D

Assigning a keyboard shortcut for the service makes this even better. Some feedback about the instructions: 1) Services folder under ~/Library may not exist (didn't on my machine), so perhaps mention that you may need to create it. 2) Is there an easy way to install system-wide? – Jonik – 2010-03-07T19:43:35.823

4

Shiney. You can also bind a keyboard shortcut to this service: "In the Application menu choose Services/Services Preferences. Open System Preferences/Keyboard/Keyboard Shortcuts/Services. Select a service, press Enter and then press your chosen shortcut key combo" (from http://www.gingerbeardman.com/services/ )

– dbr – 2009-08-31T20:25:36.587

Very nice, thanks! Does this only work on 10.6? (I'll still be on Leopard for a while.) – Jonik – 2009-08-31T22:00:48.627

1It does only work on 10.6 for now, I'm not as familiar with how Services work on 10.5 (they don't show up in the context menu, and writing a context menu plugin for 10.5 is a bit harder). – jtbandes – 2009-08-31T22:22:26.680

And, Jonik, I'd really recommend you upgrade to 10.6 if your hardware allows (i.e. you have an Intel Mac). Even if you won't get many of the speed boosts if you don't have a 64-bit machine, like I don't, the minor refinements are definitely worth the low price. – jtbandes – 2009-08-31T22:34:20.103

[ Yes, I will upgrade, as soon as I get it. :) Just that I very recently bought a Mac mini, which still came with Leopard, and it probably takes a little while before I get Snow Leopard through http://www.apple.com/macosx/uptodate/. Btw, I do hope some solution is found to this annoyance before I upgrade: http://superuser.com/questions/31925/stop-play-pause-button-opening-itunes-in-snow-leopard ] – Jonik – 2009-09-01T06:17:06.710

1Is there a way to assign Shift+Del as shortcut to this service? It seems like System Preferences beeps at you for any combination that involves Del. – haridsv – 2011-09-01T16:58:50.683

GitHub changed their interface and I can't find the downloads tab. Could you put it somewhere else? – kentcdodds – 2013-02-19T17:11:12.020

@kentcdodds It's sad that GitHub killed the downloads tab! I added a zip file to the repository itself, so you should be able to directly download it from there. See the link on the wiki. Let me know if this works! – jtbandes – 2013-03-16T22:26:10.457

@jtbandes I don't see any tar/zip files in the repository... – kentcdodds – 2013-03-17T01:55:41.997

It's in the root directory, named Delete Immediately.service.zip. I put a link on the wiki page too. – jtbandes – 2013-03-17T03:47:56.380

If someone would kindly upvote this comment, I'll have enough reputation to add my own answer with screenshots. I'd like to recommend Trash Without, which is $0.99 but has convenient options like adding a button to Finder. See: http://itunes.apple.com/us/app/trash-without/id547583082?l=ru&ls=1&mt=12

– Tyler Collier – 2013-09-26T05:49:27.807

I ended up adding my answer on the sister site here: http://apple.stackexchange.com/questions/43577/can-finder-delete-a-file-directly-and-bypass-moving-it-to-the-trash/103299#103299

– Tyler Collier – 2013-09-26T05:59:46.220

8

The Terminal-less way of solving this conundrum is to cast the following spell to appease the Apple gods, like so :

Select the file to be sacrificed followed by reciting:

⌘ Delete

⌘ ⇧ ⌥ ⌫

This will send the file to Trash, and then delete the whole Trash, thus should send the victim (and all other trashed items) to oblivion.

GeneQ

Posted 2009-07-22T09:44:10.200

Reputation: 4 581

9-1 for misleading answer. What if the user didn't want to empty his trash? – hasen – 2009-08-29T21:01:19.580

3-1 also, the original question mentions that emptying the system wide trash "Not particularly convenient!", which is what that shortcut does.. – dbr – 2009-08-31T20:21:57.157

Cool, thanks! Right now I cannot confirm if this works, but if so, it's exactly what I wanted :) – Jonik – 2009-07-22T11:49:48.573

12What this does is first deleting the file, then emptying the trash. While its a useful keyboard shortcut, it doesn't really address the issue of being unable to easily delete selected files. – Daan – 2009-07-22T11:59:38.970

1Agreed Daan. It's not ideal. But using rm in the Terminal is also not an ideal and rather un-Mac way of doing things. Our friend Jonik will have to weight the pros and cons I guess. ;-) – GeneQ – 2009-07-22T12:07:52.883

Thanks for the clarifying comments! So yeah, it's not exactly what I wanted after all, but good to know the shortcut for emptying trash. Out of the options presented so far, I'd probably go with rm on the command line, although I agree with GeneQ that it's a rather un-Mac way for a task like this. – Jonik – 2009-07-22T18:42:19.267

4

To delete a specific file, without going through the trash..

  • open a Terminal
  • type rm (with a trailing space), or rm -r if you plan to remove a directory
  • drag and drop the file onto the Terminal window, which enters the full path to the dropped file
  • hit enter

jtbandes's "Delete Immediately" service solution is much more elegant, but the "Terminal way" doesn't require any additional software (so is good when working on machines that you don't regularly use)

dbr

Posted 2009-07-22T09:44:10.200

Reputation: 4 987

+1, thanks for the drag and drop onto Terminal tip – Jonik – 2009-08-31T22:01:51.040

Thanks for the useful tip, based on your suggestion I have made a simple cocoa app, here is the link: http://daemonconstruction.blogspot.in/2013/01/mac-os-x-shift-delete.html

– Devarshi – 2013-01-07T15:26:38.963

@Miraaj Glad the answer was useful! The download link in your blog-post is broken (the link contains the next sentence, rather than a URL) – dbr – 2013-01-08T09:57:27.743

@dbr.. thanks for informing me.. I have updated it now :-) – Devarshi – 2013-01-13T09:01:00.130

2

I use rm -rf in the command line. It deletes a lot faster and it deletes everything. A common problem I have with Windows is that deleting is a process rather than a point in time and I often find myself watching Windows delete folders and files for several minutes. Rm -rf is quick.

You can also use rm -rf to delete a specific Trash. The trash can is a hidden folder named .Trash in the root of the relevant volume or directory.

And yes, I think this is how it should be. Users shouldn't be able to delete files too quickly using Finder. Files should be recoverable from the Trash.

Andrew J. Brehm

Posted 2009-07-22T09:44:10.200

Reputation: 4 411

Why the down-vote??? – Andrew J. Brehm – 2012-11-15T21:17:12.337

Note that if space in the Trash is not counted as space used, files in the Trash will be overwritten over time and cannot be recovered any more. So the choice is really between keeping files in the Trash and suffering the space hit or not keeping files in the Trash and having more space available. Combinations between the two are unpredictable for a normal user. – Andrew J. Brehm – 2009-07-22T09:59:06.467

4This is good advice, but I think that it should be made extremely clear to the unwary/non-savvy that rm -rf needs to be used extremely carefully; it will erase everything in the folder you pass to it, including the folder, without confirmation. If a system folder is passed into this command, you can do enough damage to require you to reinstall the operating system (While the permissions should keep you from destroying the system, I tend to try not to rely on them). – Babu – 2009-07-22T19:35:50.840

2

Part of the beauty of Mac OS X is that while it's dead easy for inexperienced users to find their way around and get stuff done, power users can "fiddle with the system" by using the power of the underlying Unix via a command shell (i.e. Terminal.app).

@Leauki is right about using the unix command rm, but BE VERY CAREFUL, particularly if using the -rf flags! There's no safety-net and you can do serious damage, up to and including deleting your own root filesystem!

My recommendation is not to use absolute paths with rm, but to cd into the diretory you want to work with first, and then for example:

rm -rf ./<subpath to file to delete> where the ./ in the path forces rm to operate only in the directory you're currently in.

avstrallen

Posted 2009-07-22T09:44:10.200

Reputation: 520

5rm -rf bin - oops I forgot to cd, but I'm not in / so not so big an oops. rm -rf /bin - oops I forgot to type . so BIG OOPS! (regardless of where I've cd'd to)! So I disagree. – Paused until further notice. – 2009-07-22T10:48:29.203

@Dennis - yep, if you forget to type the period you're in a world of pain! I guess this is the main reason Apple doesn't want their average user doing this kind of stuff, hence the Trash functionality the OP was taking issue with. So, I agree with your disagreement, but it sounds like you and I are experienced *nixers who respect the command shell as the potentially dangerous place we know it to be. I was only suggesting that less experienced users get into a habit of mind before using potentially dangerous commands. – avstrallen – 2009-07-22T11:14:08.347

Thanks. I agree that it's easy enough to do it on command line. But in this case I don't especially like having to resort to that... On Mac OS, you're not supposed to have to use the command line for common, end-user kind-of things, IMHO, and freeing up space on a USB stick is a pretty common thing to do. – Jonik – 2009-07-22T11:55:16.143

I agree with @GeneQ and @Daan - but I have a methodological workaround: I don't put anything in the Trash until I know for sure I'm done with it and then empty the Trash immediately every time... problem solved. – avstrallen – 2009-07-22T12:55:27.323

1

I came up with the following applescript, which I bound to shift del with Keyboard Maestro, so it now works as in windows. With the item selected in Finder, shift del will run the script, which displays a dialog warning of the permanent deletion of the item with its name. Clicking OK completes the delete.

I don't know much about shell commands, and some of the previous posters warned of the danger of using rm -rf, which is something I have done in the script. It seems to work as predicted for me so far though.

tell application "Finder"
    set myPosixPath to selection as text --returns an alias path
    set myPosixPath to POSIX path of myPosixPath --set it to posix style path with backslashes

    --identify whether it's a file or folder. Only for the warning dialog.
    if character -1 of myPosixPath is "/" then
        set itemType to "folder"
    else
        set itemType to "file"
    end if

    --display a warning
    display dialog myPosixPath & "

This cannot be undone." with title "Really permanently delete this " & itemType & "?"
do shell script "rm -rf " & quoted form of myPosixPath --execute a shell script to delete the item
end tell

fatboy

Posted 2009-07-22T09:44:10.200

Reputation: 11

for all the things that Mac OS X doesn't already provide, there's Keyboard Maestro. – Kaushik Gopal – 2011-07-29T03:59:26.797

0

I think that this is done for user consistency, and safety. I think that is better to keep files for longer than required and use space instead of being gung-ho and deleting them straight away.

This is a bit annoying though when you are working with USB sticks and you move them to a windows machine and go ... where is all my space ... and what is this annoying .trash folder.

Bruce McLeod

Posted 2009-07-22T09:44:10.200

Reputation: 5 490

0

Use muCommander for deleting files (it's free)

Instead of using the Finder then perhaps use another file manager such as muCommander. It can delete files and move files to the trashcan as well. It's much safer than pasting "rm -rf" into a Terminal, where you risk pasting the wrong commands causing damages that are irreversible.

neoneye

Posted 2009-07-22T09:44:10.200

Reputation: 725

0

If you really want to use a third party App, a much cheaper alternative to RAW Trash that you mentioned is File Shredder. (US Mac App Store $3.99)

It offers several ways to securely delete files:

  • A one-pass normal deletion that just overwrites your files.
  • A seven-pass DoD compliant pass makes sure most people can't get into your files.
  • A 35-pass Gutmann deletion ensures that your files are truly gone when you delete them.

This might be a bit overkill for most people, although if you are looking for a cheaper way than RAW Trash to securely delete files FileShredder gets the job done.

Simon

Posted 2009-07-22T09:44:10.200

Reputation: 4 193