You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Finding myriad locked files

I have a large number of locked files spattered all over my external HD in various places. I want to find them all and unlock them all - but not one by one. Is there an easy way to find locked files?

12" PowerBook G4, G4 450 DP tower, Mac OS X (10.3.9), on the Powerbook, and 10.4.2 on the G4 450

Posted on May 13, 2007 2:57 PM

Reply
Question marked as Top-ranking reply

Posted on May 13, 2007 7:50 PM

Open the Terminal in the /Applications/Utilities/ folder and type in the following:

chflags -R nouchg

followed by a space. Next, drag the external hard disk into the Terminal window and press Enter; all locked files on the drive owned by your account will then be unlocked. To do this with files owned by other accounts, use 'sudo chflags -R nouchg' without the quote marks, and provide your password when prompted, which won't produce anything in the Terminal window. Occasionally, a locked file or folder cannot be unlocked through this method, and requires the use of either Single User mode commands to unlock or erasing the drive.

(21590)
11 replies
Question marked as Top-ranking reply

May 13, 2007 7:50 PM in response to Tom in London

Open the Terminal in the /Applications/Utilities/ folder and type in the following:

chflags -R nouchg

followed by a space. Next, drag the external hard disk into the Terminal window and press Enter; all locked files on the drive owned by your account will then be unlocked. To do this with files owned by other accounts, use 'sudo chflags -R nouchg' without the quote marks, and provide your password when prompted, which won't produce anything in the Terminal window. Occasionally, a locked file or folder cannot be unlocked through this method, and requires the use of either Single User mode commands to unlock or erasing the drive.

(21590)

May 15, 2007 11:59 AM in response to Tom in London

Hi Tom

Are you aware that you can batch unlock a group of files, by selecting all of the files in any finder window, including unlocked files, then Control + mouse click to open the contextual menu, to choose Get Info, (or Command + i to open it that way) and click on the locked box to unlock all of them.

Note if you only select All locked files the locked box will show as a tick. Click on it to unlock all.
If there is a mix of locked and unlocked, the locked box will appear as a dash. Click on this Twice to unlock all.

This does not answer how to find these files in one go, but it should help you unlock in batch quantities.

regards roam

May 15, 2007 1:45 PM in response to roam

Roam,

Thanks, that might help too, but the trouble is, this is a large archive containing 100s of folders, each folder in turn with many subfolders, all containing files, only some of which are locked here and there at random all over the drive.

If there was some simple way of identifying a file that is locked, that would make it easier to find each one. Unlocking each one would not then be a major hassle.

May 16, 2007 2:39 AM in response to Tom in London

Hi Tom,

Open the Terminal application.
Type:

cd
and a space. Now drag the hard drive icon on the Desktop to the Terminal window. This will produce the absolute path to the drive at mount point /Volumes. The text should look similar to this:

cd /Volumes/<your hard_drivename>
Press the return key. You are now in the directory that contains the contents of your external drive.
To search for locked files use this command:

find . -flags uchg

If you receive any permissions error then:

sudo find . -flags uchg

Use this command to remove the lock on the files found:

sudo find . -flags uchg -exec chflags nouchg {} \;

May 18, 2007 8:00 PM in response to Tom in London

Tom
About entering passwords in Terminal.
- if permission is denied then you need to preface the command with
sudo
after you press enter you will be asked for a password, which will be entered invisibly, i.e. no little asterisks will appear.
Also if the terminal process is a long one, there will be no little spinny wheel or clock showing duration, you will just have to wait until the process completes and the terminal prompt returns.

So Neil's solution, first posted will work. I played with it and it works. It will for you too, if you understand about entering the password in Terminal.

roam

May 19, 2007 3:52 AM in response to Tom in London

all I get with find . -flags uchg is find: ./.Trashes: Permission denied


You can't look at the .Trashes folder (directory) unless you are the superuser (root). The find command did not locate any files locked with the user immutable flag (that's the lock you apply in the Finder's Get Info window) in any other directory.

all I get with sudo find . -flags uchg is a password request, and then no response when I input my password


To expand on roam's response-
A command prefaced with sudo will run the command with root privileges. The prompt will change to password:. When you input your password nothing is printed (echoed) in the shell (Terminal app). Enter your password then press the return key.

There are other locks that can be placed on files though uncommon. You can search for all the possible locks with the following instructions.

cd /Volumes/<your external_hard_drivename>

This mean change to the directory that contains the contents of the external hard drive where <your external_hard_drivename> is the actual name of the drive. The find command can take an usually long time. It's best to limit its searches.

This command will search for all possible locks and list what locks are applied:

sudo find . -flags +arch,nodump,opaque,sappnd,schg,uappnd,uchg -exec /bin/ls -aol {} \;

The . after the find command tells find to search the current directory (folder) and all sub-directories. -flags +arch,nodump,opaque,sappnd,schg,uappnd,uchg are the possible locks. -exec /bin/ls -aol {} \; tells the find command to list any files found in long format with what lock is applied to the file.

If the find command does not produce any output then there are no locked files on the external hard drive.

Jun 11, 2007 8:03 AM in response to Mark Jalbert

well, this didn't work either. As suggested, I typed in the following:

sudo find . -flags +arch,nodump,opaque,sappnd,schg,uappnd,uchg -exec /bin/ls -aol {} \;

and this is what returned:

-rw-r--r-- 1 root unknown nodump 29196288 20 May 2006 ./Temporary Items/501/Cleanup At Startup/1577307 MVM0
-rw-r--r-- 1 root unknown nodump 0 20 May 2006 ./Temporary Items/501/Cleanup At Startup/1577307 MVM1
-rw-r--r-- 1 root unknown nodump 0 20 May 2006 ./Temporary Items/501/Cleanup At Startup/1577307 MVM2

Jun 11, 2007 1:32 PM in response to Tom in London

well, this didn't work either.


Hmmm...actually the command did exactly what is was supposed to do. Find files with all the possible locks. The three files found have the nodump flag(lock) applied. Two of the files are empty- 0 bytes.

The external drive looks like it's set to ignore permissions or may be it was initialized with OS 9 or less. Post the command and the results from the following instructions-
Type:

vsdbutil -c

and a space. Now drag the external hard drive icon on to the Terminal window; this will produce the absolute path from the mount point /Volumes. Press the return key. This should be an easy fix.

Finding myriad locked files

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.