Skip to main content
Solved

Empty Trash via Script in El Cap and newer?


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.

View original
Did this topic help you find an answer to your question?

4 replies

mm2270
Forum|alt.badge.img+16
  • Legendary Contributor
  • 7880 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

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


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings