Dealing with Locked Files on a Mac

Quite often, I am asked one of two related questions: 1) "Why can't I delete this pesky file? My Mac says the file is locked, and I can't delete it unless I do something special!" or 2) "Gaa! I can't copy <insert name here> to my flash drive or another hard drive because it's locked—help!"

Locked Trash File - Hold down Option to Delete

Well, I will answer those questions, and much more, after the break.

Why Lock a File?

There are a few different reasons why someone would want to lock a file. For one, locking a file makes it unchangeable. Let's say you have five or six versions of a document you're working on, but you want to make absolutely sure you don't delete or change the original. Well, if you lock the file (click on the file and choose "File > Get Info..." or press "Command (Apple key) + I"), then you won't be able to modify or delete the file without a warning appearing.

Another common practice is for certain programs to contain locked files in them; and sometimes there are tons of them. This is a simple method of copy-prevention, as you are unable to move the files to another volume on your Mac. Both of these methods for locking files can cause a lot of consternation, though!

Deleting or Changing a Locked File

To delete a locked file, the process is pretty simple. If you want to delete one locked file, move it to the trash, and when you click "Empty Trash..." or press "Shift + Command (Apple) + delete," make sure you hold down the Option key. For multiple locked files, hold down Shift and Option while you empty the trash.

Changing or moving locked files can be a burden, though. You can click on the file, choose "Get Info..." or press "Command + I," then uncheck the 'Locked' checkbox, but what if you have a bunch of files to unlock? Luckily, there are a few shortcuts that you can use to unlock these files:

  • The quickest method is to select all the files you want to unlock, then press "Option + Command + I" (or hold down Option while choosing "Get Info..." from the File menu) to open one Info pane for all of them. Then uncheck the 'Locked' checkbox, and you're done!
  • Another method, a little more involved, but possibly better for certain situations (like files spread through a variety of folders), is to open up the Terminal (in Applications > Utilities) and enter:
    chflags -R nouchg DIRECTORY_NAME (where the DIRECTORY_NAME is the path to the parent folder.
  • A third method is to download a utility like LockMeBaby (from Soramimi Works) which performs the above steps for you.

Whatever you decide to do, make absolutely sure you are deleting the right files—there's usually a reason someone went through all the trouble of locking a file!

Comments

Joshua - that's an interesting (and handy!) Windows app! I haven't seen an equivalent app on the Mac, even though there have been a few times (very rare, though) when I tried to delete a file or eject a volume, only to have a window appear saying "This file [or disk] is in use. Please quit the application using it and try again." The problem is, of course, that you have no idea what program is using the file!

I usually just restart my Mac if this ever happens, but I guess having a program like WhoLockMe could be quite helpful, too!