GPSAltitude math operation across photos by date/time created bracket...

Started by wbtc, September 19, 2016, 04:02:46 PM

Previous topic - Next topic

wbtc

Hey gang,

gotta say, as much as I have huge respect for exiftool and the supplementary gui, this has been the most painful learning curve in memory for me. I have what I believe is a simple use case for exiftool and I cannot seem to find in the documentation the correct way to address the task.

I need to change the GPSAltitude for batches of photos by variable amounts based on date. So lets say I discover in my initial photo processing that ever photo taken on Sept 10th before 12:00 needs to have it's GPSAltitude changer by -90, what command or set of commands do I input? I've spent an inordinate amount of time on this problem already and am close to abandoning the whole attempt for another solution.

Would hugely appreciate any help you guys could offer.

StarGeek

Here's what I found worked (assuming Windows, if not swap single and double quotes):
exiftool -if "$datetimeoriginal ge '2015:09:10 00:00:00' and $datetimeoriginal lt '2015:09:10 12:00:00'" "-GPSAltitude<${GPSAltitude;$_-=90}" FileOrDir

I used DateTimeOriginal to compare time as most modern cameras set that value, you may have to look for a different time tag.

To break it down:
The -if option checks to see if the time is greater than or equal to midnight on Sept 9, 2015 and less than (but not equal to) 12 on the same day.  The ge and lt are perl string comparison operators (see here for more examples).  If the file date is outside those limits, it won't be processed.
"-GPSAltitude<${GPSAltitude;$_-=90}"  This will copy GPSAltitude back into the same tag, but will use the advanced formatting to subtract 90 from it first.  If you need to add altitude, use += instead of -=.


And then question for Phil.  I first tried -GPSAltitude-=90 but it didn't change the value (ver 10.26).  If I add a value though (-GPSAltitude+=90) it works fine.  Bug or am I missing something?
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

Phil Harvey

Quote from: StarGeek on September 19, 2016, 04:57:05 PM
And then question for Phil.  I first tried -GPSAltitude-=90 but it didn't change the value (ver 10.26).  If I add a value though (-GPSAltitude+=90) it works fine.  Bug or am I missing something?

For backward compatibility, the -TAG-=VALUE syntax is a conditional delete for a non-list-type non-date-time tag.  -TAG+=VALUE increments a numerical value, but VALUE may be negative, so you can do -TAG+=-VALUE to decrement.  Perhaps I should document this.  It is a bit confusing I know.

So the command is:

exiftool -if "$datetimeoriginal ge '2015:09:10 00:00:00' and $datetimeoriginal lt '2015:09:10 12:00:00'" "-GPSAltitude+=-90" FileOrDir

- Phil

Edit:  I've added a note to the documentation:

       -TAG[+-]=[VALUE]
            Write a new value for the specified tag (eg. "-comment=wow"), or
            delete the tag if no VALUE is given (eg. "-comment=").  "+=" and
            "-=" are used to add or remove existing entries from a list, or to
            shift date/time values (see Image::ExifTool::Shift.pl and note 6
            below for more details).  "+=" may also be used to increment
            numerical values (or decrement if VALUE is negative), and "-=" may
            be used to conditionally delete or replace a tag (see "WRITING
            EXAMPLES" for examples).
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

StarGeek

* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).