ExifTool Forum

ExifTool => Newbies => Topic started by: sylloge2 on May 04, 2020, 12:45:39 AM

Title: Math add two fields
Post by: sylloge2 on May 04, 2020, 12:45:39 AM
-n -tagsFromFile @ -RelativeAltitude+=2
-n -tagsFromFile @ -AbsoluteAltitude+=2

both add 2m to the field

what is the syntax to add them together

-n -tagsFromFile @ -AbsoluteAltitude+=-RelativeAltitude
gives
Warning: Shift value for XMP-drone-dji:AbsoluteAltitude is not a number

I won't go into the dozen alternative attempts that didn't work!@#

Thanks
Title: Re: Math add two fields
Post by: StarGeek on May 04, 2020, 12:58:42 AM
Try
exiftool -TagsFromFile @ "-AbsoluteAltitude<${AbsoluteAltitude;$_-=$self->GetValue('RelativeAltitude')}" /path/to/files/

Example
C:\>exiftool -g1 -a -s -*Altitude y:\!temp\Test4.jpg
---- XMP-drone-dji ----
AbsoluteAltitude                : 30
RelativeAltitude                : 20

C:\>exiftool -P -overwrite_original -TagsFromFile @ "-AbsoluteAltitude<${AbsoluteAltitude;$_-=$self->GetValue('RelativeAltitude')}" y:\!temp\Test4.jpg
    1 image files updated

C:\>exiftool -g1 -a -s -*Altitude y:\!temp\Test4.jpg
---- XMP-drone-dji ----
AbsoluteAltitude                : 10
RelativeAltitude                : 20


The name of the tag in the GetValue function is case sensitive and must be the exact name.
Title: Re: Math add two fields
Post by: sylloge2 on May 04, 2020, 01:34:14 AM
Thanks !