One-click automated USB trash delete Is there any way I can create an automator service or app to delete ALL trash from any USB drive (my own account's trash plus everybody else's)?

I've read several solutions involving Terminal, including this one, but I'd like something a bit more foolproof and really handy.

I need to exchange USB drives regularly for presentations at events and Mac trash is becoming a problem as Macs become more common -- people suddenly get "no space available" error messages and can't do anything about it. I know how to skip the trash, but need a quick fix when the trash is already there.
2 Solutions. 1 using Bash the other using Bash wrapped in AppleScript.

Solution #1


Create a new AppleScript with /Applications/Utilities/AppleScript Editor
Type the following code:

do shell script "rm -rf /Volumes/*/.Trashes/*" with administrator privileges

Save the file to somewhere convenient and run it whenever you need to clear the USB Trash
This can be executed by double-clicking on it


NOTE: This will empty the Trash for all connected volumes including your internal hard disk. If you have connected 5 USB drives and a Firewire hard disk, it will empty the trash for all of them.



Solution #2


Fire up your favourite text editor (mine is nano)
Paste the following code into your text editor and save the file

#!/bin/bash  
sudo rm -rf /Volumes/*/.Trashes/*

Save the file to somewhere convenient with the extension .sh and then make it executable with chmod +x {filename}.sh from Terminal
Run that with ./{filename}.sh


NOTE: Same note as above. This is executable from Terminal.