In response to a newsgroup request for a way to unlock files from the command line I wrote this script. Note that it uses developer tools SetFile and GetFileInfo (so you'll need the Dev Tools installed for this to work).
Read the rest of the article for the cut-and-paste script and instructions.
Start a terminal and type these three commands (the stuff after the ">"):
prompt > cd
prompt > mkdir bin
prompt > cat > bin/unlock
Once you've done that, copy and paste the following:
#!/usr/bin/perl
use strict;
my $ask = ($ARGV[0] == "-i");
shift if $ask;
$| = 1;
foreach my $file (@ARGV) {
my $locked = `/Developer/Tools/GetFileInfo -al $file`;
chomp $locked;
next unless $locked;
print "Unlock '$file' ? " if $ask;
if (!$ask or (<STDIN> =~ /^y/i)) {
print STDERR "Unlocking $filen";
print STDERR `/Developer/Tools/SetFile -a l $file`;
}
}
##### hit control D here after pasting #####
Now type:
prompt > chmod +x unlock
prompt > rehash
Now you're ready to use it. Call it either with:
unlock filename
unlock filename1 filename2
unlock *
or
unlock -i *
The "-i" file makes the script interactive, it prompts you to confirm you want to unlock the file.
Mac OS X Hints
http://hints.macworld.com/article.php?story=20010907150339649