ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: Harald on March 03, 2017, 09:48:49 AM

Title: multiple "IF" conditions
Post by: Harald on March 03, 2017, 09:48:49 AM
Hi again Phil,
I want to apply a photographers name based on the Camera Model. I have read the thread
https://exiftool.org/forum/index.php/topic,4682.msg22369.html#msg22369
and tried to alter your suggested line
exiftool -if "$Model eq 'NIKON D200'"  -Nikon:CameraSerialNumber=6007814 -execute if "$Model eq 'DSC-V3'"  -EXIF:CameraSerialNumber=7559435 -common_args DIR

LIKE THIS: (working Mac I swapped ' with ")
exiftool -if '$Model eq "NIKON D700"'  -XMP:Creator="Losang Sherab" -execute if '$Model eq "DMC-GM1"'  -XMP:Creator="Holly Ansett"  -execute if '$Model eq "ILCE-6300"'  -XMP:Creator="Losang Sherab"   .

RESULT:
No file specified
Error: File not found - if
Error: File not found - $Model eq "DMC-GM1" 
    0 image files updated
    2 files weren't updated due to errors
Error: File not found - if
Error: File not found - $Model eq "ILCE-6300" 
    1 directories scanned
   23 image files updated
    2 files weren't updated due to errors

It seems not to correctly interpret the "if" in the "-execute" part, right?

I am not really into Unix and the solution you suggested in that article with user defined tags is a bit above my level :) So I prefer to do it with multiple "-execute if". Is that possible? Thanks a lot in advance for your help.

Have there ever been Exiftool user group meetings or seminars? I would love to get some proper training on it, as it is a great tool but try and error is not a great way of learning :)
Title: Re: multiple "IF" conditions
Post by: Phil Harvey on March 03, 2017, 10:22:03 AM
Hi Harald,

You forgot the "-" before two of your -if options.

There aren't any seminars for ExifTool, but I think you will catch on quickly.

- Phil

Edit:  Oh.  Also you need to add -common_args before the directory (.) in your command so that argument applies to all of the -execute commands:

exiftool -if '$Model eq "NIKON D700"' -XMP:Creator="Losang Sherab" -execute -if '$Model eq "DMC-GM1"' -XMP:Creator="Holly Ansett" -execute -if '$Model eq "ILCE-6300"' -XMP:Creator="Losang Sherab" -common_args .

This is equivalent to executing these 3 commands:

exiftool -if '$Model eq "NIKON D700"' -XMP:Creator="Losang Sherab" .

exiftool -if '$Model eq "DMC-GM1"' -XMP:Creator="Holly Ansett" .

exiftool -if '$Model eq "ILCE-6300"' -XMP:Creator="Losang Sherab" .

But a bit faster because you only have to load exiftool once.  (Although harder to understand when combined into a single command line.)
Title: Re: multiple "IF" conditions
Post by: Harald on March 06, 2017, 04:11:25 AM
Hi Phil,

thanks a lot, worked like a charm. Actually I noticed that missing "-" but it was written like that in your own comment
https://exiftool.org/forum/index.php/topic,4682.msg22369.html#msg22369
and I was to stupid to give it at least a try and see whether it would work. I just could not imagine you could have made a mistake, as I thought the other guy would then have noticed and commented on it. Well, now I know :)
And I think it is really time for the first Exiftool-User Group meeting :)
What you think?
:)
Thanks a lot for your help again.
best,
harald
Title: Re: multiple "IF" conditions
Post by: Phil Harvey on March 06, 2017, 08:30:34 AM
Hi Harald,

Yes.  That was a mistake in my old post.  I've edit the post to avoid further confusion.  Thanks.

As far as meetings go, I think an ExifTool-User Group meeting would be a real sleeper. ;)

- Phil