I wanted to build an awesome place for people to discuss module specific issues, but I don't have any more time for this, and there are much better places to discuss Perl-related issues. I'd recommend asking your question on Stack Overflow or on Perl Monks.
If you are looking for a Perl tutorial or Perl-related news, I hope these links will serve you well.
Posted on 2009-11-12 02:11:54-08 by msbc
Updating Lens tag fails using -if option
Hi,

I'm updating some NEF's to add Lens data after using a manual focus lens. I'm also using the -if option to only process NEF's missing this data in a folder.

I've found that the following command works as expected:
exiftool -P -Lens="21mm f/2.8" -MaxApertureValue="2.8" -FNumber=11 -FocalLength=21 Zeiss.NEF
Then, executing
exiftool -Lens -MaxApertureValue -FNumber -FocalLength -ext NEF .
I get
======== ./Zeiss.NEF Lens : 21mm f/2.8 Max Aperture Value : 2.8 F Number : 11.0 Focal Length : 21.0 mm
But, if I use an -if option as follows (FNumber does equal 0 for these files):
exiftool -P -Lens="21mm f/2.8" -MaxApertureValue="2.8" -FNumber=11 -FocalLength=21 -n -if '$FNumber eq 0' Zeiss.NEF
Then the result is:
======== ./Zeiss.NEF Lens : 0mm f/0 Max Aperture Value : 2.8 F Number : 11.0 Focal Length : 21.0 mm
Three tags are updated but Lens is not.
exiftool 7.99 on OSX 10.5.8
Direct Responses: 11749 | Write a response
Posted on 2009-11-12 15:46:20-08 by exiftool in response to 11748
Re: Updating Lens tag fails using -if option
The problem is simple, but maybe not obvious:

If you use the -v2 option you will see the following message (among lots of others):

"Not enough values specified (4 required) for Nikon:Lens"

It is the -n option that is causing you the problem, not -if. The Nikon:Lens tag must be converted to numerical form when writing, and the -n disables this conversion so the tag is not written because the input string is in the wrong format.

Please let me know if you have any more problems.

- Phil

P.S. You get points for trying this with the most recent ExifTool version before posting this.
Direct Responses: 11751 | Write a response
Posted on 2009-11-12 21:24:39-08 by msbc in response to 11749
Re: Updating Lens tag fails using -if option
Phill

Can you help me with the -if part then. If I simply remove -n the condition fails.
Output from exiftool -FNumber Zeiss.NEF:
Mark:Testing$ exiftool -FNumber Zeiss.NEF F Number : 0.0
but the condition fails with 0.0.

Could you also enlighten me what the 4 required values for Nikon:Lens are?
Direct Responses: 11754 | Write a response
Posted on 2009-11-13 11:38:59-08 by exiftool in response to 11751
Re: Updating Lens tag fails using -if option
I'm sorry, I should have thought of this. You can either do a string compare:

-if '$fnumber eq "0.0"'

or a numerical compare:

-if '$fnumber == 0'

or you could do what you were originally doing but use "#" to return the numerical value of this tag only (instead of using -n which applies to all tags):

-if '$fnumber# eq 0'

Take your choice. :)

- Phil
Direct Responses: Write a response