Automatically remove Trash from usb sticks
I think most Mac users have had this problem; You delete a bunch of files from your pen drive to make room for a large file, and it keeps complaining about lack of space.
The problem is that when you remove files on Mac, they're just moved to a hidden folder named '.Trashes', so they are actually still there. A commonly suggested solution is to empty the Trash while the USB stick is plugged in, but this might be problematic in some cases where you want to keep your Trash, just in case...
My new solution is to set this little script as a folder action, it will remove the trash only from the USB stick as soon as you mount it(unmount proved problematic).
Save this script to /Library/Scripts/Folder Action Scripts/ and now set it as the folder action for /Volumes.
You might need to show hidden files in Finder for /Volumes to be visible. To do this, follow this guide.

on adding folder items to this_folder after receiving these_items
do shell script "rm -rf " & POSIX path of these_items & ".Trashes/"
end adding folder items to
Posted on Friday, Feb 19, 2010

1 Comment
Leave a Comment