Wishful Coding

Didn't you ever wish your
computer understood you?

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...

Automatically remove Trash from usb sticks

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).
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
Save this script to /Library/Scripts/Folder Action Scripts/ and now set it as the folder action for /Volumes. Automatically remove Trash from usb sticks You might need to show hidden files in Finder for /Volumes to be visible. To do this, follow this guide.