Easy Trashing

/ 13 January 2007

You know how you may throw something away and then forget to ever actually empty the trash. Well, with a combination of Applescript, and the helpful Finder addition of Folder Actions, I’ve made a way so I’ll never forget to empty my trash if I just put something in it. The trick behind this helpful script is knowing what folder the Trash contents lives in before you empty the trash. I figured this out by looking at Finder in the hidden mode that is accessible with a simple UNIX shell script (“defaults write com.apple.finder AppleShowAllFiles TRUE”), and looking at my user accounts home folder. In that folder is a folder named “.Trash”, this is the folder hidden behind the Trash in your dock. Now, the trick here is to make an alias of this folder and drag it to your desktop. From here on out you can revert Finder back to its default version (“defaults write com.apple.finder AppleShowAllFiles FALSE”). Now, you can go to the folder action setup app (/Applications/Applescript/Folder Actions Setup.app) and choose to setup actions for the alias you’ve just created. Instead of creating actions for the alias, your computer knows to create actions for the hidden folder, so from here you can get rid of the alias if you want. At this point you need to make an applescript that has the command “empty trash” somewhere in it (I made a dialog that asks if you want to empty the trash first, and if you press yes {which isn’t the default answer} it executes the “empty trash” command), but you can decide what you want to do. In the end, I’ve made a script that will ask me if I want to empty my trash whenever I add something to the trash.