Skip to main content
Solved

Empty Trash via Script in El Cap and newer?

  • March 15, 2017
  • 4 replies
  • 21 views

Forum|alt.badge.img+8

I know you used to be able to run a simple rm -r (user)/.Trash command to empty the trash, but that doesn't seem to be the case in El Capitan and newer - you're supposed to drag all the files in the Trash to the terminal window and then run the command.

Is there some way to automate that process so I could include it in a general first aid Self Service policy?

Best answer by mm2270

It should work if you do:

rm -R /Users/username/.Trash/*

The * wildcard tells it to match any files in the user's hidden trash directory. If that doesn't work, post back. I can't imagine it won't work though.

4 replies

mm2270
Forum|alt.badge.img+24
  • Legendary Contributor
  • 7886 replies
  • Answer
  • March 15, 2017

It should work if you do:

rm -R /Users/username/.Trash/*

The * wildcard tells it to match any files in the user's hidden trash directory. If that doesn't work, post back. I can't imagine it won't work though.


Forum|alt.badge.img+8
  • Author
  • Contributor
  • 71 replies
  • March 15, 2017

That's a bingo!


Forum|alt.badge.img+15
  • Esteemed Contributor
  • 719 replies
  • March 16, 2017

@duffcalifornia I'm curious to know what the scenario is where you'd want to delete everything in a User's trash.


Forum|alt.badge.img+7
  • Contributor
  • 94 replies
  • March 20, 2017

Does not work in El Cap or Sierra.

Some files when deleted are in the trash but are not listed in the .Trash directory or it's sub directories anymore.

For example, here is a file that i just dragged to the trash and it's location:

/Users/robertbasil/Library/Mobile Documents/com~apple~CloudDocs/.Trash/1Password-6.3.1.zip