Mar 13, '07 07:30:04AM • Contributed by: CajunLuke
rm -r /Volumes/Vingilot/.Trashes/510/*
Where Vingilot is the drive name, and 510 is your user number. (Every user account has a number associated with it - root is 0, and the account you make when you first start Mac OS X is 501. You can see all the numbers for your accounts in Terminal by typing ls -ln /Users.)To automate this task, I wrote an AppleScript droplet. Drop a single drive on the file, and it will empty the trash on that drive. Here's the code:
on open dropped_item
tell application "Finder"
set drivepath to POSIX path of dropped_item
end tell
if drivepath is "/" then
display dialog "This doesn't work on your boot volume."
else
set uid to the third word of (do shell script "id")
set trashpath to drivepath & ".Trashes/" & uid & "/"
beep
set confirm to display dialog ¬
"Empty the trash on " & drivepath & ¬
"?" buttons {"No", "Yes"} default button "No"
if button returned of confirm is "Yes" then
display dialog "The deleted items on " & drivepath & ¬
" were deleted."
do shell script "rm -r " & trashpath & "*"
end if
end if
end open
Paste this into Script Editor and save it as an application. Put it in you sidebar or somewhere convenient, then drag and drop a volume onto the application to use it. The advantages of this method are:
- You only empty your own trash, not anybody elses' (unless they're on another computer and have the same UID as you)
- The script doesn't ask for authentication, so it's not likely to bork anything.
- The script checks to make sure you're not doing this in your startup drive, where stuff is stored in different locations.
[robg adds: I tried this script, and it worked as described.]
