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: 296
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
 

PressWise

A 30-day Fix for Managed Chaos

As any print professional knows, printing can be managed chaos. Software that solves multiple problems and provides measurable and monetizable value has a direct impact on the bottom-line.

“We reduced order entry costs by about 40%.” Significant savings in a shop that turns about 500 jobs a month.


Learn how…….

   
Back
Top