can I selectively empty trash on usb stick without emptying desktop trash?

So I know this question has been asked on the forums before: can i selectively empty the trash on my usb stick without emptying the trash on my desktop. The answer back in 2008 was no! OSX didn't allow that sort of selective trashing. Various risky (ie rm in terminal) or timeconsuming (temp folders) workarounds were offered. Does anyone know if mountain lion has solved this problem?


By way of explanation: I work with hundreds of thousands of image files every day, and need to create space on usb drives daily. But I also don't want to lose my desktop trash everyday - sometimes its a lifesaver and my desktop harddrive has plenty of space to spare for my unwanted files. Using a temp file doesn't work for my 'flow' so I'm just hoping that mountain lion has some hidden feature that I can use to selectively empty my usb drives.

iMac, OS X Mountain Lion (10.8.4)

Posted on Oct 16, 2013 11:25 PM

Reply
35 replies

Feb 17, 2015 5:52 AM in response to muswellbrook@icloud

The PERFECT SOLUTION....

works perfectly, does what is needed, for all of us who use our trash bins as circular filing cabinets.


Thanks to Jacques Rioux and iorganutan


I use this script AppleScript, save it as Application :


on open these_volumes

set t_id to user ID of (system info)

repeat with i in these_volumes

if (kind of (info for i without size)) is "Volume" then

set tPath to (POSIX path of i) & ".Trashes/" & t_id

do shell script "/bin/rm -Rf " & (quoted form of tPath) & "/*"

end if

endrepeat

end open

----------------------------------------------

Drag/Drop Volume(s) on the application.


This script removes the items from your trash (user ID) folder on the volume.

if other users use the volume this script will not delete the items from their trash folder, otherwise the script would need an administrator password to do that.



----------------------------------------------

If you want to eject the volume after emptying the trash, use this script.


on open these_volumes

sett_idto user ID of (system info)

set volToEject to {}

repeatwith i in these_volumes

if (kindof (info foriwithoutsize)) is "Volume" then

set tPath to (POSIX path of i) & ".Trashes/" & t_id

do shell script "/bin/rm -Rf " & (quoted form of tPath) & "/*"

set end of volToEject to contents of i

end if

endrepeat

ifvolToEjectisnot {} thentellapplication "Finder" toejectvolToEject

end open



Discussion over.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

can I selectively empty trash on usb stick without emptying desktop trash?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.