One-click automated USB trash delete
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 withchmod +x {filename}.sh
from Terminal - Run that with
./{filename}.sh
NOTE: Same note as above. This is executable from Terminal.