Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Another AppleScript to re-create the desktop trash Desktop
This is an AppleScript droplet I've been using to reproduce the trash icon functionality on my desktop, like on old-style Macs. Why? Because you're never sure where the trash icon is going to be on your screen in the OSX dock -- it jumps about, if you have a lot of apps open, it will be in one corner, if not, it will be closer to the middle. I'm not the only one with this peeve.

Like the normal trash icon, and unlike other ways of doing the same thing, this script can trash files on any attached disks, and you can also drag disks to it to unmount them. Double-clicking it lists the contents of the trash. I've only tried this on 10.3. Others have written similar scripts, but I haven't seen the source.

To hide the icon from the dock when it runs, you need to save the script as an application bundle. If you want to be even more old-school, you can give this droplet an icon from /System -> Library -> CoreServices -> SystemIcons.bundle -> Contents -> Resources -> TrashIcon.icns.
on run
  tell application "Finder"
    if Finder window "Trash" exists then
      open window "Trash"
    else
      make new Finder window to trash
    end if
  end tell
end run
	
on open these_items
  repeat with i from 1 to the count of these_items
    set this_item to (item i of these_items) as alias
    set this_info to info for this_item
    tell application "Finder"
      try
        eject this_item
        delete this_item
      end try
    end tell
  end repeat
end open
Bug: aliases can't be trashed unless they're in folders. If anyone knows why I'd love to know.

[robg adds: I tested the script, and it works as described on files, folders, and disks. Personally, I only trash things via Command-Delete or (rarely) the Delete icon on the Finder toolbar. There are also third-party solutions, such as Drag Thing, that will enable the desktop trash, but this script is both free and effective.]
    •    
  • Currently 2.25 / 5
  You rated: 1 / 5 (4 votes cast)
 
[7,956 views]  

Another AppleScript to re-create the desktop trash | 5 comments | Create New Account
Click here to return to the 'Another AppleScript to re-create the desktop trash' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Another AppleScript to re-create the desktop trash
Authored by: wgscott on Mar 22, '04 10:39:08AM

Have a look at how Gary Kerbaugh's rmm applescript deals with symbolic links and aliases: http://www.cs.ecu.edu/~collins/rm/rm.html

I'm sure he wouldn't mind if you used this or asked him for advice.



[ Reply to This | # ]
Another AppleScript to re-create the desktop trash
Authored by: Richard Morton on Mar 26, '04 02:14:20AM

> Bug: aliases can't be trashed unless they're in folders. If anyone knows why I'd love to know.

The 'open' handler automatically resolves aliases. This is system level (Alias Manager) and the same reason why an alias dropped onto any app opens the original rather than the alias.



[ Reply to This | # ]
Another AppleScript to re-create the desktop trash
Authored by: PancakeMan on Mar 22, '04 12:06:54PM
This works as advertised on Jaguar. I'm going to stick with my old alias to .Trash solution, though, since this script isn't nearly as responsive, and its limitations don't bother me.

By the way, to keep the dock trashcan in the same place, I pin the dock to the end position with Tinkertool, as has been mentioned here before.

[ Reply to This | # ]
Another AppleScript to re-create the desktop trash
Authored by: mcramer on Mar 22, '04 04:06:13PM
Because you're never sure where the trash icon is going to be on your screen in the OSX dock -- it jumps about, if you have a lot of apps open, it will be in one corner, if not, it will be closer to the middle. I'm not the only one with this peeve.

Am I the only one tired of this particular complaint? I mean really...were you *ever* able to drag something to the trash without looking? And it's not like it goes from one side of the screen to the other. It's going to move *at most* about 45% of the width of your screen -- and that's only with a totally empty dock. But dissing the dock is cool I suppose...

Plus, it's *far* easier to just right click on the icon and "move to trash".

[ Reply to This | # ]
Non-Applescript solutions
Authored by: jscarry on Mar 22, '04 07:58:38PM

This was probaly covered before but, you can also use the free Tinkertool app to pin the trash to the bottom of the screen when the dock is on the left or right side.

Or you can use TextEdit to edit the ~/Library/Preferences/com.apple.dock.plist file and add two lines near the end.
<key>pinning</key>
<string>end</string>
The last two lines of the file remain as:
</dict>
</plist>
Restart the dock and the trash is always at the bottom of the screen.

I put an alias for my hardrive just above it and an alias for my local server just above that and I always know where to find them.



[ Reply to This | # ]