10.3: Use Folder Actions to add the trash to the sidebar

Nov 05, '03 08:46:00AM

Contributed by: Anonymous

Here's how you can use Panther's Folder Actions to create an icon for the Trash on your desktop, or the Finder toolbar/sidebar. Note that the icon won't change depending on whether there are items in the trash.

  1. Launch Script Editor and type in this code:
    
    on adding folder items to thisfolder after receiving theseitems
      tell application "Finder"
        repeat with i in theseitems
          move i to trash
        end repeat
      end tell
    end adding folder items to
    
    on opening folder thisfolder
      tell application "Finder"
        set target of the front window to trash
      end tell
    end opening folder
    
    Save the script to ~/Library -> Scripts -> Folder Action Scripts and name it "Trash."
  2. Create a folder on your desktop named "Trash." You'll probably want to change its icon to match the Trash.
  3. Enable Folder Actions by control-clicking on the Desktop and choosing "Enable Folder Actions".
  4. Control-click on the folder "Trash" and choose "Attach a Folder Action." Browse to ~/Library -> Scripts -> Folder Action Scripts (if it's not already selected) and choose "Trash." as the script to use.
And you're done. You can add this folder to the Sidebar in Finder windows, or right-click the Toolbar and choose "Customize" and then drag this folder onto your Finder toolbar.

[robg adds: An anonymous hintster sent in another method -- use Tinkertool to make your hidden files visible, find the .Trash folder in your home directory and drag it to the sidebar and/or toolbar, then disable viewing hidden files. Paste a custom icon as you wish. I think the Folder Action Scripts method is cleaner, in that you'll be moving things to the "real" trash as opposed to the one in your home folder. For example, I'm not sure what happens when you drag a file from another volume into your local .Trash icon -- does it copy it to your local trash while leaving it on the other hard drive?]

Comments (7)


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