Recently I tried to empty the trash on my Mac only to be continuously prompted with "cannot delete, file is locked".
I found the guilty party was Windows Media Player (because the best place for that on a Mac is the trash - use VLC instead!).
It didn't really matter what the file was, I couldn't remove it. So here's how I did get rid of it.
UK EVENTAttend ffconf.org 2024
The conference for people who are passionate about the web. 8 amazing speakers with real human interaction and content you can't just read in a blog post or watch on a tiktok!
£249+VAT - reserve your place today
I opened the Terminal app. I then entered the hidden Trash directory in my home folder:
cd ~/.Trash
Note that I found the trash directory using two commands, the first located the directory in question, the second shows me hidden files when running 'ls':
locate .Trash
The dot indicates it's hidden.
ls -ltrFa
Shows all the files (including hidden) in the current directory - quite handy as a default.
Once I'm certain where the .Trash directory is, I run the following command (in my particular case I'm getting rid of Windows Media Player):
sudo su - cd /Users/remy/.Trash/ rm -rf Windows\ Media\ Player/
After I type 'sudo su -' I am prompted for my password. Please be very careful with 'rm -rf' it recursively removes all the files in given directory without prompting for confirmation. Use it carefully, or don't use it at all.
Now I went back the Trash in OS X, and ran 'Empty Trash' and it went about it's business cleaning up the remaining files.