ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: johnha on May 25, 2012, 01:53:02 AM

Title: Using the Lock button on Nikon DSLRs (tagging read-only files)
Post by: johnha on May 25, 2012, 01:53:02 AM
Hi,

I'm trying to use ExifTool to help me tag read-only files from my Nikon.  My Nikon DSLR (D800E) has a button with a little key (the protect button). What I'd like to do is use the button to quickly mark photos that I like when viewing on the camera screen. Then when I get back to my computer, I'd like to have that be reflected in my workflow, perhaps as a flagged file in Lightroom.

If I copy the files directly to my hard drive using Finder (on Mac), the icon in OSX has a little lock indicating a read-only file. But if I import using Lightroom, the read-only flag is wiped.

So my solution is to directly copy only the files with the flag first, import those into Lightroom, then flag them all. Then import the rest of the files. But this is cumbersome and I'm hoping to use ExifTool to tag the files for me.

This is exactly the same request as this fellow:

https://exiftool.org/forum/index.php/topic,2571.msg11345.html (https://exiftool.org/forum/index.php/topic,2571.msg11345.html)


I'm on OSX and would ideally like some sort of automated way to handle this.  I used to use batch files on Windows, but I'm unfamiliar with how the process could be accomplished on OSX.

Thanks kindly,
John
Title: Re: Using the Lock button on Nikon DSLRs (tagging read-only files)
Post by: Phil Harvey on May 25, 2012, 07:34:39 AM
Hi John,

From the thread you referenced, the relevant -if expression to test for a locked file on a Mac seems to be:  -if '$filepermissions=~/^.w/'

I did a quick search, but I couldn't find any metadata that corresponds to a flag in LR, but maybe something like this would help:

exiftool -if '$filepermissions=~/^.w/' -subject+=locked DIR

which should add "locked" to the XMP:Subject (ie. keywords) of any locked file in directory DIR.

- Phil
Title: Re: Using the Lock button on Nikon DSLRs (tagging read-only files)
Post by: johnha on May 26, 2012, 01:50:32 AM
Hi Phil,

Thanks so much for your quick and accurate reply.  I gave it a shot, but it appears to do the exact opposite of what I expected.  I created a directory called "tmp" and put in 4 NEF files, three read-only (locked) and one regular.  The result I got was the regular (unlocked) file had the keyword "locked" added, and the read-only files were untouched.  Here is what I wrote and the resultant output:


exiftool -if '$filepermissions=~/^.w/' -subject+=locked tmp

Error renaming tmp/_DSC1681.NEF
Error renaming tmp/_DSC1693.NEF
Error renaming tmp/_DSC1742.NEF
    1 directories scanned
    1 image files updated


Would appreciate any ideas you might have about this.  Perhaps since the files are read-only, ExifTool can't change them?  I tried with sudo in from of exiftool to no avail.

Thanks kindly,
John
Title: Re: Using the Lock button on Nikon DSLRs (tagging read-only files)
Post by: Phil Harvey on May 26, 2012, 05:49:51 AM
Hi John,

Oh, right.  You probably don't have write privileges on the locked file. :P

Before you started, what where the FilePermissions of the files?  It seems that the -if condition isn't correct.

Also, you will need to write the locked files to a different directory since you can't modify the oriiginals.  This is done with -o DSTDIR.

- Phil
Title: Re: Using the Lock button on Nikon DSLRs (tagging read-only files)
Post by: johnha on May 27, 2012, 03:55:55 PM
Hi Phil,

I did an ls -lO and it returned the following output:

-rwxrwxrwx  1 John  staff  -    44564017 May 27 14:45 _DSC1788.NEF
-rwxrwxrwx  1 John  staff  -    44709210 May 27 14:45 _DSC1789.NEF
-rwxrwxrwx  1 John  staff  -    42925888 May 27 14:51 _DSC1792.NEF
-rwxrwxrwx  1 John  staff  uchg 45935899 May 27 14:56 _DSC1793.NEF

I believe the column with the "uchg" for the file "_DSC1793.NEF" indicates that it is a locked, or read-only, file.

Apologies for my ignorance - is this the information were referring to when you asked for the FilePermissions of the files?

Thanks so much,
John
Title: Re: Using the Lock button on Nikon DSLRs (tagging read-only files)
Post by: Phil Harvey on May 28, 2012, 07:04:13 PM
Hi John,

Actually, I was expecting to see a change in permissions.  From -rwxrwxrwx to -r--r--r-- or something maybe.  Removing write permissions on a file would effectively lock it.

But apparently this uses another mechanism that I am not familiar with.  I'll have to look into this.

- Phil
Title: Re: Using the Lock button on Nikon DSLRs (tagging read-only files)
Post by: johnha on May 29, 2012, 10:53:26 AM
Hi Phil,

Yes, I was a bit confused by that too.  Because it looks like the unix permissions are all the same, it's just the "uchg" flag that's different.  I found that this is the 'user immutable' flag.  http://hints.macworld.com/article.php?story=20031017061722471

and http://www.thexlab.com/faqs/immutableflags.html

But of course, I'm uncertain how to translate those attributes into something that exiftool can recognize.

Thanks so much for all your help,
John
Title: Re: Using the Lock button on Nikon DSLRs (tagging read-only files)
Post by: Phil Harvey on May 29, 2012, 11:01:01 AM
Hi John,

In general, ExifTool does not recognize system-dependent attributes, which appears to be the case here.  It seems like this locked attribute exists in OS X, and the FAT filesystem on your memory card, but probably not Unix filesystems, hence I don't think there is a standard C library interface to access this information.

- Phil
Title: Re: Using the Lock button on Nikon DSLRs (tagging read-only files)
Post by: johnha on May 29, 2012, 11:30:57 AM
Hi Phil,

I did an ATTRIB on the CF card itself, from Windows this time, and it returned these results:

H:\DCIM\100D800E>attrib
A    R       H:\DCIM\100D800E\_DSC1859.NEF
A            H:\DCIM\100D800E\_DSC1860.NEF


So if it recognizes the first file as a read-only file, I wonder if just asking exiftool if to select the read-only files would work.


Thanks again,
John
Title: Re: Using the Lock button on Nikon DSLRs (tagging read-only files)
Post by: Phil Harvey on May 29, 2012, 12:10:23 PM
What are the exiftool FilePermissions for the files on the memory card?

- Phil
Title: Re: Using the Lock button on Nikon DSLRs (tagging read-only files)
Post by: johnha on May 29, 2012, 12:29:11 PM
Hi Phil,

I'm using the GUI and it shows r-- r-- r-- for the locked file and rw- rw- rw- for the other file.

Thank you,
John
Title: Re: Using the Lock button on Nikon DSLRs (tagging read-only files)
Post by: Phil Harvey on May 29, 2012, 12:39:30 PM
Now this is what I expected.  If you can find a way to preserve these permissions when you transfer the image to your hard disk, then you can use the FilePermissions in a Condition as mentioned in an earlier post.

- Phil
Title: Re: Using the Lock button on Nikon DSLRs (tagging read-only files)
Post by: johnha on May 29, 2012, 02:07:03 PM
I'm now working in Windows.  What I did was copy the two files into a folder called lock and I created an empty folder called dest.  Then I did this:

C:\Users\John\Downloads>exiftool -if '$filepermissions=~/^.w/' -subject+=locked lock -o dest
    1 directories scanned
    2 files failed condition
    0 image files read

I verified with the gui that the file permissions are as I described previously.

I also tried with OSX, and it does in fact do something, but when I check in Lightroom, both files are tagged with the "locked" keyword.

I'm grateful for your help with this.  Thank you!

-John
Title: Re: Using the Lock button on Nikon DSLRs (tagging read-only files)
Post by: Phil Harvey on May 29, 2012, 06:39:38 PM
Hi John,

In Windows you need to use double quotes.  Single quotes as you had are for Mac/Linux.

- Phil
Title: Re: Using the Lock button on Nikon DSLRs (tagging read-only files)
Post by: juju22 on September 09, 2014, 08:48:14 AM
Just a comment for the archives, as I'm probably the fellow who posted the other thread (can't verify as the link is dead here and for google too)

On Linux, I'm using this command as input for exiftool tagging (need fatattr package)
find "$src" -type f -iname '*.JPG' -exec fatattr {} \;) | egrep '^r' | sed "s@^.*$src@@;"

On Mac, with the information of this thread, you can just use the input of
find "$src" -type f -iname '*.JPG' -flags uchg
(Attention! try to avoid spaces in path...)

and do something like :)
exiftool $exiftool_arg -ext jpg -rating=1 -keywords+='_d90lock' $filelist

Enjoy!