Sure, Recycling is Important but…

10/28/2009 – 12:13 am

Windows has an option in the recycle bin preferences that allows the user to skip the recycle bin when deleting files. That preference has been available as far back as I can remember and it was on a short list of options I would tweak when setting up a new Windows computer. I have never had occasion to pull something out of the Trash or Recycle bin in my twelve or so years of computing, but I have emptied these buggers more times than I would like to admit. In it’s infinite wisdom, neither OS X nor Gnome/Nautilus allow me to do what Windows has offered for the past decade.

On OS X I had always hacked around this by changing the hidden trash folder, ~/.Trash into a file – which confounds whatever cat-named operating system I am running and pops up a dialog telling me that the file will be deleted immediately since it cannot be written to the trash. This hack fails in two ways, first I have to see a dialog, second sometimes the system would get confused and end up with the trash full icon.

I decided to actually fix this the right way tonight. Yes, I could actually pay for software which can do this – but that is rather silly. I hacked around with someone else’s AppleScript and set it up as a folder action to automatically empty the trash when I put something into it. This pops up no dialogs and gives me a satisfying flip-flop of the trash icon from full to empty. Maybe you want this too… I dunno, but here it is.

on adding folder items to this_folder after receiving added_items
try
set trash_files to (list folder this_folder)
repeat with i from 1 to the count of trash_files
set a_file to alias ((this_folder as text) & (item i of trash_files))
set sh_script to "rm -rf " & quoted form of (POSIX path of a_file)
do shell script sh_script
end repeat
end try
end adding folder items to

  1. 2 Responses to “Sure, Recycling is Important but…”

  2. So… I tried this out, and it seems to work great. Just like you said, as soon as I delete a file, I get the sound and the trash can icon fills and then empties. But now I can’t figure out how to get my file back. When I go into the trash/recycle can thing, the directory is empty. I had a lot of stuff in there I really needed. It isn’t gone now, is it? How do I access those files? Quick response appreciated, as I had some files I need for work that were in there, and I have to finish this project this weekend.
    Thanks! And neat script!

    By david on Jan 16, 2010

  3. Only took me two months to check the comments – I am sure your files couldn’t have been that important :)

    By Ryan on Mar 9, 2010

Sorry, comments for this entry are closed at this time.