A relatively safe method of deleting trashed locked files

Aug 24, '06 07:30:00AM

Contributed by: CaseV8

Recently I found myself wanting to get rid of Windows Media Player 9. I used AppZapper to get all the application components in the trash, but then I was unable to delete it because files (specifically .htm files) deep within the contents of the app are locked. So after a little research, I came across this fairly simple solution and figured I'd share it:

Warning: Typographical error or misuse of the following rm -rf command can result in serious data loss. Insertion of a space in the wrong place could result in the complete deletion of data on your hard disk, for example. You may wish to copy and paste the commands below into a text editor to verify spacing. Follow these steps to delete Trash for the logged-in user:

  1. Use a program like AppZapper to get all WMP components in the trash.
  2. Open the Terminal application, in /Applications -> Utilities.
  3. In Terminal, type sudo rm -rf[space]. Don't type [space] literally; just press the space bar on the keyboard. Do not press Return.
  4. In Finder, open your Trash.
  5. Choose Select All from the Edit menu.
  6. Drag the selection (all) from the Trash window into the Terminal window. This causes the Terminal window to automatically fill in the name and location of each item in your Trash.
  7. Press Return.
Now your computer will be free from Windows Media Player. Hope this helps!

[robg adds: As noted in a previous hint, if you hold down Option before you select Finder: Empty Trash, then locked items will be deleted (or just use the Dock's contextual menu, apparently, as noted in a comment to that hint). But the above method may be useful if you have a really stuck file in the trash. By using drag and drop, you can use sudo rm -rf in a relatively safe way -- it will only act on those items you specifically dropped onto the command in Terminal. It's still a very dangerous command, of course, but used in this manner, it's about as safe as possible.]

Comments (15)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20060820101328778