Deleting OS X Files: Just the Unlocked Items?

deleting os x files

Today, I was cleaning up some old USB thumb drives and thought I found some “new pictures” which were not on my laptop. So, I copied the “new pictures” to my local hard drive and reformatted the thumb drive. Looking around, I figured out that these new items were not new at all — they were just named differently. Logically, my next action was to trash them. But, when I went to empty the trash, I received an error message, “There are some locked items in the Trash. Do you want to remove all the items, including the locked ones, or just the unlocked items?” The problem was that no matter which button I clicked: “Cancel”, “Removed Unlocked Items”, or “Remove All Items”, these files persisted in the trash bin–deleting them did not work. How could I delete them?

At first, I assume this was a privilege problem. Since you cannot view or alter trashed files, I used the “Put Back” feature, moved them into a Junk folder, and started recursively changing privileges. Trashing them again, I received the exact same error result. So, if its not a rights problem, what is locking them? Well, here’s the answer that actually worked for me.

  1. Create a Junk folder:
    • Open Finder
    • Navigate to your Documents folder
    • Create a new folder called “Junk”
  2. Move files into Junk folder:
    • Right-click Trash and use the Open menu item
    • Highlight the files, right-click and use the “Put Back” menu item
    • Finder should open to the location from which the files were removed
    • Highlight the files and drag them to a folder you named “Junk”
      (Note: moving them to “Junk” is optional, but it makes the next step clearer)
  3. Run the unlock command:
    • Open a Terminal window by clicking Applications | Utilities | Terminal
    • Change directory to your “Junk” folder: cd Documents\Junk
      (Note: remember that directories are case sensitive)
    • Validate you are in the Junk folder: pwd
    • Run the unlock command: chflags -R nouchg *
    • Close the terminal window using command-Q or the Terminal | Quit Terminal menu item
  4. Trash the files:
    • Back in Finder, highlight all the files you want to delete
    • Right-click and the “Move to Trash” menu item
  5. Empty the Trash bin:
    • Right-click Trash and use the Open menu item
    • Right-click and use the “Secure Empty Trash” menu item
      (Note: yours may say only “Empty Trash”)

Which brings me to another point. If your trash bin menu only says “Empty Trash” without the word “Securely” this means you have not enabled this additional security feature. To enable the feature, run Finder, select the Finder | Preferences menu item, goto the Advanced tab, and check the “Empty trash securely” checkbox. Any changes you make take effect immediately, just click the red X to close the “Finder Preferences” dialog box.