• Best Wishes to all for a Wonderful, Joyous & Beautiful Holiday Season, and a Joyful New Year!

Force Empty Trash Shell Script in Automator

Stephen Marsh

Well-known member
In OS 10.11 Apple removed the option to securely empty the trash (as multiple pass overwrites are not good for SSD).

I used to use this feature to force empty the trash.

OS 10.11 often requires that an open application be quit for the trash to empty a file that was recently opened.

I searched for a terminal command to force empty the trash and I found the command as detailed in the attached image. It might be overkill, but it works…sort of:

This empties the trash OK, however it always pops up an error message that needs an OK (The action run shell script encountered an error). I am guessing that I have not setup my Automator application correctly, the command works but I would like to not have an error message requiring an OK.


Any ideas on how to fix this up?


Stephen Marsh
 

Attachments

  • force-empty-trash.jpg
    force-empty-trash.jpg
    38.1 KB · Views: 360
You can create an AppleScript, then compile it as a Run Only app. Here's the code:
tell application "Finder"
do shell script "sudo rm -rf ~/.Trash/*" user name "Administrative User Name Here" password "Administrative Password here" with administrator privileges
end tell

Cheers,
pd
 
Fantastic, thank you – that works great!


Stephen Marsh


You can create an AppleScript, then compile it as a Run Only app. Here's the code:
tell application "Finder"
do shell script "sudo rm -rf ~/.Trash/*" user name "Administrative User Name Here" password "Administrative Password here" with administrator privileges
end tell

Cheers,
pd
 

InSoft Automation

InSoft Automation Unveils Imp Version 14

Revolutionizing Layout Planning and Automation

InSoft Automation announces the launch of Imp Version 14, the latest iteration of its industry-leading cost-based layout planning software. Packed with cutting-edge features, this release redefines efficiency, automation, and workflow optimization for printing and finishing processes.


Learn more…….

   
Back
Top