Mac OS X: Two trashes are better than one!
Posted on January 2nd, 2007 | by Billifer |If you’re a Mac user like me, you indiscriminately hit Command-Delete on anything you want to fling out of your hard drive. But the truth is, there are different kinds of files–with different levels of sensitivity and security–and that one-size-fits-all actually fits none.
If you choose to merely “Empty Trash,” then any files that contain personal information can easily be recovered by mediocre crackers: cookies, names, addresses, credit card numbers, browsing history, etc. But going the other direction and choose to Securely Empty Trash for all your temporarily files, such as your grocery list, will consume time, CPU resources, memory, oh, and time.
What’s the tradeoff? Two trashes… With a little AppleScript magic, it’s quite simple to set up a second trash that accepts only sensitive data. Files, folders, and anything else you copy or move into it is immediately deleted securely, leaving your system default Trash for the mundane files like Aunt Polly’s pictures of her poodles.
Creating the Incinerator

The first step is to create a new folder on the Desktop. Call it something descriptive. I’ve chosen Incinerator because at a grocery store where I worked in high school, we burnt all our garbage. (Long story.)
Open Script Editor with this AppleScript file. (Right-click to save the file, then open it in Script Editor.)
Confirm that the location for the find and srm commands are correct for your system. (These are the standard locations for Mac OS X 10.4 Tiger.) Also, you may want to remove the -z flag from the srmFlags property, depending on your personal preference. See the srm(1) man page before changing these flags.
Save the AppleScript file to /Users/
/Library/Scripts/Folder Action Scripts/add - secure delete.scpt. Right-click your new Incinerator (or Shredder, or what-have-you), and ensure that “Enable Folder Actions” is enabled. If not, enable it.
Again, right-click your new Incinerator and click “Attach a Folder Action” (which will not appear unless you’ve succeeded in step 5). A window will open allowing you to choose the script to attach to the folder. Navigate to the location specified in Step 4 and select the file you just saved.
Tah-dah! You now have a super-duper Secure Trash-Shredder-Burn Box-Incinerator that implements the Gutmann method for secure deletion.
Extending and tweaking
Here are some ideas for making it your own.
Add a custom icon to your Incinerator, but be sure to change the permissions on the icon file so that it doesn’t get incinerated.
After adding the icon (see elsewhere on the web for assistance), open a Terminal and cd to the Incinerator folder. If you execute ls -l, you’ll see a file called Icon?. That question mark is actually a carriage return, so here’s what to type to protect the icon:
chmod a-w Icon<control-V><control-M>Alternatively, if you are using the standard bash shell with tab completion, you can simply type “Icon<Tab>” and the carriage return will be added for you.
Do away with the confirmation. You can kill the confirmation dialogue and alert box if you are really, really certain that you will never accidentally move a file into the Incinerator. In other words, I don’t recommend it.
A final note
I’ve licensed this utility under the GNU Public License (GPL). Feel free to modify it to suit your needs, make it better, or what have you. Although the license does not require it, I would appreciate a copy of any changes you should make so that I can consider integratign them into my own version. Feel free to leave them in the comments on this entry.






20 Responses to “Mac OS X: Two trashes are better than one!”
By Spencer on Jan 4, 2007 | Reply
That is awesome. Thanks for that tidbit of information. BTW, nice new theme.
By Billifer on Jan 4, 2007 | Reply
Thanks! Have you tried it out yet? I’m still playing with themes, but at least this one is usable.
By Billy Halsey on Jan 7, 2007 | Reply
What do you think of this theme? I have used it before, but I just made some modifications to it. I think it works better now.
By Alex V. on Mar 20, 2007 | Reply
Hi everybody,
did I miss something? I am absolutely new to doing anything that is a little off the “normal” interface-work. I tried to create the “Incinerator”. As I did not have a “Scripts”-Folder in my User-Library, I tried the general Hard Drive Library at first and later tried it with creating a Script-Folder in my User-Libary. I proceeded and created the folder. When I tried it, everything seemed to work and I got the message if I was really sure about deleting. Clicked on “Do it Now!” but then the whole “Incinerator”-Folder was deleted.
What am I doing wrong? Am I doing something wrong? Is this supposed to happen?
Would be happy to hear from you,
bye
By Billy Halsey on Mar 20, 2007 | Reply
Hi Alex V!
I’m not completely certain, but I think I have the solution to your problem. Under step 1 of “Extending and tweaking,” you will notice that you must set the permissions of the Icon to disallow writing (and deleting) the file.
The other thing you probably need to do to fix this is to open the folder containing the Incinerator (the Desktop, for example), get the information for the Incinerator (either by
⌘-Ior right-clicking and selecting “Get file info”), and then locking the directory. That should keep the directory from being deleted–even by a root user using therm -f(nuclear) option.Let me know if this does not solve your problem.
Best regards, Billy
By Dustin on Jan 24, 2008 | Reply
About the answer to Alex V’s question (I’m having the same problem)…If I lock that directory, doesn’t that prevent me from adding files to it? It asks me to authenticate, I type my password, and it fails to delete the just-added file, saying I lack permission to complete the operation.
By Billifer on Jan 25, 2008 | Reply
@Dustin » I was incorrect in what I wrote previously. It is unnecessary to lock the directory, but you will want to lock the Icon file (or it will be deleted).
This can be accomplished in the Terminal as mentioned above with
chmod a-w Icon<Tab>or, alternatively,chflags uchg Icon<tab>.By EZG on Apr 4, 2008 | Reply
Seems like a great idea. I tried it and had a lot of anomalies. When I downloaded the script, it had some characters–some stray quotes. I opened the script in Firefox and it had put in odd characters trying to render the end of line mark.
I deleted those quote marks and the script compiled.
I followed the directions–they’re pretty simple from that point. I got the “Do it Now!” dialog to come up. But after I told it to do it, absolutely nothing happened.
Any clues as to what might have gone wrong?
By Billifer on Apr 4, 2008 | Reply
Hey EZG –
I haven’t updated my post here, but I’m actually using a different script myself now. Try this one instead:
Add that as a folder action script to your Incinerator instead. It should work like a charm for you.
By EZG on Apr 4, 2008 | Reply
It’s taken me close to an hour to figure out what I’ve been doing wrong here and there. But I’ve got it working. Really great tip. Thanks for the updated script, too.
By Billifer on Apr 4, 2008 | Reply
Glad you got it working! Definitely makes it easier than having to run
srmfrom the Terminal every time—and using “Secure Empty Trash” only zeros the space, not the 7-pass or 35-pass wipe.By themonkman on Apr 6, 2008 | Reply
I really like the incinerator icon you have. Where oh where did you get it? BTW - I tried compiling the updated script, but it gave me the following error: Expected “”” but found unknown token. This occured at the following point: set srmScript to findCmd & ” ” & fName & ” -mindepth 1 -exec ” & srmCmd & ” ” & srmFlags & ” {} \;” Thanks!
By Billifer on Apr 6, 2008 | Reply
Hmm… I can’t remember where that one came from. I would be able to tell you, except that I’ve gone through two hard drive crashes and at least as many system reinstalls since I took that screen capture, so it’s not in my CandyBar / Pixadex catalog anymore.
Silly question, but did you try retyping that line or copying and pasting? Just to make sure I didn’t mistype it, here it is again:
set srmScript to findCmd & " " & fName & " -mindepth 1 -exec " & srmCmd & " " & srmFlags & " {} \;"There are a lot of quote marks in that line. Don’t drown in them. :) You can separate that into multiple lines if you wish for readability:
If you still have problems compiling, then email me your script—comment1241 {at} paxoo(.)com.
By Billifer on Apr 6, 2008 | Reply
DOH! Totally my own fault. Huge typo. Try an extra backslash:
set srmScript to srmScript & " {} \\;"That should do the trick. When I typed that out earlier, my Script Editor window was just the right size that the first one was the last character on one line and the second was the first character on the next line, so I only saw one of them.
By themonkman on Apr 6, 2008 | Reply
Ok, got the syntax error corrected, and your new updated script compiles. I enabled folder actions, and attached the script. When I move files into the folder, it asks me if I want to delete, and I say yes but nothing happens. The files are still there, even after waiting for 40 sec to 1 min. I’m running 10.5.2. Is there anything else I need to do? My other folder actions seem to work fine, though.
Thanks!
By Billifer on Apr 6, 2008 | Reply
You could try two things.
srm,find, etc., near the top. There should be; this indicates that these apps are running and getting CPU time.do shell scriptline to:If the secure deletion works, it should say “value = 0”. (Haven’t checked that for accuracy, and my mind is a bit muddy right now. Hope it works correctly.)
So I’d suggest trying that and see what the issue might be. It’s possible it could be that you’re trying to secure erase something you shouldn’t—I intentionally wrote the script not to prompt for the administrator password when needed, and instead to delete. You’d hate to toss
/Libraryinto the Incineratr and see your whole system go up in flames!By serenity on May 16, 2008 | Reply
“…and using “Secure Empty Trash” only zeros the space, not the 7-pass or 35-pass wipe.”
Are you sure about that? I’m pretty sure I’ve read that it uses srm, with the 7-pass option.
By Billifer on May 16, 2008 | Reply
@Serenity » From what I remember reading, Secure Empty uses
srmin the zero disk space mode. And, if you’ve ever run Secure Empty Trash on a large amount of trash, then you’ll know that there’s no waysrmcould have done a 7-pass wipe in the time that Secure Empty Trash deletes the contents of the trash. I would look it up onadc.apple.com, but I’m lazy.