Jump to content
Sign in to follow this  

Force Empty Trash

Recommended Posts



If you have multiple drives, this doesn't empty the files that were in those though. Does anyone know which folder os x puts those in?

Edited by kimroen

Share this post

Link to post



Probably need sudo privileges to get at all files though.


I have an alias:




alias emptytrash='sudo rm -rfv /Volumes/*/.Trashes; sudo rm -rfv ~/.Trash; sudo rm -rfv /private/var/log/asl/*.asl'

but that of course prompts me for my password. 


Anyone know of a way to get sudo privs in a workflow? NOPASSWD=/bin/rm  and ssh to localhost with authkeys? ... poor security though.

Share this post

Link to post

For sudo, I've been using AppleScript:

do shell script "sudo rm -rfv /Volumes/*/.Trashes; sudo rm -rfv ~/.Trash; sudo rm -rfv /private/var/log/asl/*.asl" with administrator privileges

You get prompted with a standard OS X authentication dialog box.

Share this post

Link to post

The script doesn't work because you MUST enter a password to sudo. I've modified Sebbo's commands as you might need the Apple System Logs, and  put it into an NSAppleScript command. So here it is. This script will work on locked and busy files, which is why you'd force empty the trash, right? You've been warned.


For any sudo command, you MUST put it into an NS and not a background OSA script because you have to enter your admin password ONCE for every sudo session. That's just how Unix (even in OSX) works. So yes, you will get that auth dialog, you'll key in your admin password (you're on the sudo'ers list, right?), then feel remorse as that file is never coming back.




The most current version that I'll be tweaking will be at Github:




This was hacked together late last night on a whim with no coffee. Then modified today, still no coffee.


Test: Locked file on the desktop, move to trash.


Original v2 script: FAIL

      This v2 script: PASS


Do as thou wilt.


-Leo (don't make me read forums late at night)

Edited by leoofborg

Share this post

Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  
  • Create New...