Automatically empty the trash when items are trashed

Aug 06, '03 09:47:00AM

Contributed by: bog

I recently had a friend who is in the midst of switching ask me if it's possible to have the Trash automatically emptied when you drag items to it. Apparently this is an option in Windows, but there is a way to do it in Mac OS X as well. So, I thought others might find it useful.

You need to have Folder Actions enabled in order to do this -- double-click the AppleScript menu.menu file in /Applications -> AppleScript (if you haven't done so before), then click the script icon in the menu bar and select Folder Actions -> Enable Folder Actions.

Here are the steps:

  1. Create and save this AppleScript (using Script Editor in /Applications -> AppleScript) in the /Library -> Scripts -> Folder Action Scripts:
    on adding folder items to this_folder after receiving added_items
      try
        tell application "Finder" to empty
      end try
    end adding folder items to
  2. From the Folder Actions menu in the Script icon in your menu bar, choose "Attach Script to Folder." Then choose the script you just created. When it asks what folder to attach it to, type ~/.Trash in the Go text field and press Return. Then click Choose.
After you do this, the Finder will automatically empty the trash every time you put items in it. Use with extreme care.

[robg adds: A couple of comments on this one ... first, it's obviously quite dangerous! Once dragged to the trash, the item is gone for good. Second, I prefer to keep my folder action scripts particular to my user, so I store them in my user's Library -> Scripts -> Folder Action Scripts folder, not the system-wide Library. You may have to create this folder structure if you've not done so previously. Finally, I tested this script, and it works as described ... after proving that point, I disabled the script (Script menu -> Folder Actions -> Remove Folder Actions) immediately, as I don't trust myself that much!!]

Comments (9)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20030804230855953