Use -if $model and "not $GPSLatitude" to determine whether to geotag photos

Started by Wilfred C, October 18, 2024, 02:41:13 PM

Previous topic - Next topic

Wilfred C

Hi, firstly what an amazing tool, a massive thank you for writing this program!

I have multiple folders of photos which I am trying to geotag using a csv file. On my trips I usually shoot with two (or more) cameras with all the photos in the same folder, because of how the dates are set up in each camera/phone I need to run different command lines.

I was hoping to use these two commands:

exiftool.exe -if '$Model="ONEPLUS A3003"' -execute -if "not $GPSLatitude" -geotag history2016Dec.csv -geosync=-8:00:00 -geolocate=geotag -EXIF:OffsetTime*=+08:00 Folder -P -r

exiftool.exe -if '$Model="NIKON D7100"' -execute -if "not $GPSLatitude" -geotag history2016Dec.csv -geosync=-58:00 -geolocate=geotag "-AllDates+=0:0:0 7:02:0" -EXIF:OffsetTime*=+08:00 -makernotes:timezone+=480 Folder -P -r

I was testing these with 3 images - 2 shot from the ONEPLUS A3003, and 1 shot from the NIKON D7100.

For the first command, I was expecting Exiftool to process only images that were shot on my ONEPLUS A3003 phone, and didn't already have a GPS Latitude value. It seems to only geotag the 2 images from the ONEPLUS A3003, which is good, but for the 1 shot from the NIKON D7100 it doesn't geotag but still carries out the offset time change. Actually I think I found the reason for this, as I'm getting this error:
Warning: Time is too far from nearest GPS fix 2349.96900010109 > 1800 in File:Geotime (ValueConvInv) - Restore/DSC_3393.JPG
For the second command, I was expecting Exiftool to process only images that were shot on my NIKON D7100, and didn't already have a GPS Latitude value. Instead it processed (geotagged and offset time) all 3 images. I was wondering if it had something to do with having two -if statements so I tried removing one but still got the same outcome:

exiftool.exe -if '$Model="NIKON D7100"' -geotag history2016Dec.csv -geosync=-58:00 -geolocate=geotag "-AllDates+=0:0:0 7:02:0" -EXIF:OffsetTime*=+08:00 -makernotes:timezone+=480 Restore -P -r

When I run the last command with -v2 these are the errors I get:
Condition: Bad name after Model' - Folder/DSC_3393.JPG
Condition: Bad name after Model' - Folder/IMG_20161222_191631.jpg
Condition: Bad name after Model' - Folder/IMG_20161222_191648.jpg

So in fact my if statement based on $model doesn't seem to be working at all, even when just used by itself.

I am thinking perhaps I need to combine both -if statements using the "and" operator, but I don't know how to do this.

Please can I get help on what I'm doing wrong? Thanks!

StarGeek

The first thing to clarify is what command line you are using.

If you are using Windows CMD, then it needs to be double quotes outside, single quotes inside
-if "$Model eq 'ONEPLUS A3003'"

On Mac/Linux, it's the reverse
-if '$Model eq "ONEPLUS A3003"'

You should also note that I change the command to use the eq string comparison operator. The equal sign the way you were using it would be to set the value of $Model equal to "ONEPLUS A3003", which would always be true. The operator for numeric equal comparison is ==.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

Wilfred C

Thank you! I am using Windows and I didn't understand the distinction between that order and Linux, but after much experimentation I did finally get it to work, using this:

exiftool.exe -if "$Model=~'NIKON D7100' and not $GPSLatitude" -geotag history2016Dec.csv -geosync=-58:00 -geolocate=geotag "-AllDates+=0:0:0 7:02:0" -EXIF:OffsetTime*=+08:00 -makernotes:timezone+=480 Folder -P -r 2>log.txt

It was this thread: https://exiftool.org/forum/index.php?topic=2129.0 that helped me to understand the distinction between = and =~, I couldn't get it to work using eq as I must have been using the wrong order of parentheses at the time.