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.

Locking all files in a folder.

I've my photos currently in a dated folders - I'd like to be able to lock them all at the same time.

I've experimented with locking the top level folder, but, unlike Windows, which asked me if I wanted to lock sub-folders/anything in them, this just seemed to do the top level. Individual files didn't seem to be locked.

I've done a bit of a search & LockMeBaby ( http://soramimi-works.net/software.shtml ) seems to do what I want it to. Is it what i need, or is it possible from within Snow Leopard to (easily!) lock files in multiple folders all at the same time.

Also, if I do lock the folders will it be like Windows in that I can still add files to the folders - it just grumbles when I either delete them or try to re-save them after editing.

Mac Mini, Mac OS X (10.6.1)

Posted on Nov 15, 2009 7:38 AM

Reply
Question marked as Top-ranking reply

Posted on Nov 15, 2009 7:47 AM

Emmadw wrote:
I've my photos currently in a dated folders - I'd like to be able to lock them all at the same time.

I've experimented with locking the top level folder, but, unlike Windows, which asked me if I wanted to lock sub-folders/anything in them, this just seemed to do the top level. Individual files didn't seem to be locked.

I've done a bit of a search & LockMeBaby ( http://soramimi-works.net/software.shtml ) seems to do what I want it to. Is it what i need, or is it possible from within Snow Leopard to (easily!) lock files in multiple folders all at the same time.

there is no built in tool for this but you can easily make one. this is esy to do from terminal. the following terminal command will lock everything inside a given folder


chflags -R uchg /path/to/folder


and this one will unlock everything


chflags -R nouchg /path/to/folder



you can automate this if you wish. you can make a service using automator which will be in the right click menu in finder and lock everything recursively.
Also, if I do lock the folders will it be like Windows in that I can still add files to the folders - it just grumbles when I either delete them or try to re-save them after editing.


no, if you lock a folder you won't be able to add anything to it while it's locked.
10 replies
Question marked as Top-ranking reply

Nov 15, 2009 7:47 AM in response to Emmadw

Emmadw wrote:
I've my photos currently in a dated folders - I'd like to be able to lock them all at the same time.

I've experimented with locking the top level folder, but, unlike Windows, which asked me if I wanted to lock sub-folders/anything in them, this just seemed to do the top level. Individual files didn't seem to be locked.

I've done a bit of a search & LockMeBaby ( http://soramimi-works.net/software.shtml ) seems to do what I want it to. Is it what i need, or is it possible from within Snow Leopard to (easily!) lock files in multiple folders all at the same time.

there is no built in tool for this but you can easily make one. this is esy to do from terminal. the following terminal command will lock everything inside a given folder


chflags -R uchg /path/to/folder


and this one will unlock everything


chflags -R nouchg /path/to/folder



you can automate this if you wish. you can make a service using automator which will be in the right click menu in finder and lock everything recursively.
Also, if I do lock the folders will it be like Windows in that I can still add files to the folders - it just grumbles when I either delete them or try to re-save them after editing.


no, if you lock a folder you won't be able to add anything to it while it's locked.

Nov 15, 2009 8:45 AM in response to Barney-15E

Umm... I don't think so; I tend to download them to a folder - then use iPhoto to put them into iPhoto - creating a copy en-route ... so I guess the originals aren't the ones I'd be editing normally anyway; but I'd feel safer if they were locked!

Thanks for the terminal info - will have to sort that out, as it's really the files in folders I want locking, not the folders themselves.

Nov 15, 2009 10:18 AM in response to Barney-15E

Thanks - that seems to work.

I'm not too familiar with commands that you put into the terminal, so I've tried to look them up:

The first part seemed obvious - putting in the path to the folder & getting it to find all the files in that folder ... then setting the flag to uchg (which is the "locked" I wanted. http://ss64.com/osx/ seemed quite a useful source of commands. I wasn't sure, though, what {} + meant; I wasn't able to find them in any of the examples of how to use find / exec / chflags, nor could I find them via search.

Guess I need to learn some more!

Nov 15, 2009 10:24 AM in response to Emmadw

Taking it a step further…
Create a new Automator Service with Service receives 'folders' in 'Finder'
Drag a Run Shell Script action from the Utilities Library
Change it to Pass Input: Arguments
Add this code: {code}find "$@" -type f -exec chflags uchg {} +
Save it as something like "Lock files". You can then use it by right-clicking on a folder and selecting "Lock files" from the Services menu.
You can make a similar one with nouchg instead.

I will leave it as an exercise for the reader to test a file in the folder for the locked bit and then toggle uchg/nouchg so you'd have a single service which either locks or unlocks the files.

Nov 15, 2009 11:19 AM in response to Barney-15E

Ok, I couldn't leave it. Here is the code for the Automator do shell script action:
if [[ ! "$(find "$@" -type f -flags uchg)" ]]; then
find "$@" -type f -exec chflags uchg {} +
else
find "$@" -type f -exec chflags nouchg {} +
fi
That will toggle the locked/unlocked setting. You can make just one service that will toggle the locked/unlocked status. It took a while to get the if condition to work. It seems the [ -n "$var" ] (is var not empty) does not work in Automator. It works fine in a shell.

Nov 15, 2009 12:05 PM in response to V.K.

I should have caveated that. I chose locked, but perhaps unlocked makes more sense as when you add a new file, it will be unlocked. Then, when you toggle it, I would assume you want them locked. If they are locked, and you add a new unlocked file, the next logical step would be to Lock them. If you unlock for editing and then add a new file, Locked is the next logical step.

Right now, it says if there are no locked files, then lock them; otherwise unlock them. In the add to locked files case, it would unlock. If you set it for no unlocked files (nouchg in the if condition), then unlock, it would work better. I suppose you could make more conditions, but I think if you just change the uchg to nouchg and vice versa, the toggle works as expected. Not perfect, but better.

Locking all files in a folder.

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