a cesspool of interwebness

Destroy All Locked Files

Posted by Unknown On 2010-05-01 2 comments

So, I use rar, zip and 7z across my PC and Mac, and recently after password protecting an archive, copying it to another machine and unarchiving it, I discovered that I had somehow set the "Locked" attribute. When unpacking files on my Mac I was suddenly having a couple of problems... I couldn't delete the files or manipulate them in a editor (Logic in this case) without getting various 'file is locked' / 'insufficient privileges' messages. Annoying.

We're not talking about 2 or 3 files here, but a directory full of samples and loops that I use for music production. The thought of manually going through each files "info" dialog and unchecking a box made me throw up a little in my mouth - there is ALWAYS a way to script or automate this kind of shit.

After a little digging I was able to uncover this little gem:

sudo chflags -R nouchg ~/

What the hell does that mean you ask? I know it looks like it has the word douche in there, at least, that's all I could see initially, but I'll explain.

sudo will run the chflags command as root (this prompts you for your root password, so I hope you know it).

-R will cause the command to affect every file in the directory and all of its subdirectories. Make sure it's uppercase, as it's case-sensitive.

If uchg is the flag for "Locked" in the info dialog, then nouchg is the syntax for removing the uchg flag.

The tilde (~) indicates that you want to run this command against your home directory. If you have only a subdir inside your home directory you can path it out (I used ~/Music/Resources/SampleBank23/ and it worked a treat).

2 comments:

ScrewLoose said...

uchg and nouchg are some non obvious sounding flags. Thanks for bringing them up as I'm sure I'll run into this at some point.

Unknown said...

update: we had to do the same operation on Ruxpin's MBP and we verified this works as advertised