ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: gheppell on May 22, 2020, 01:33:16 PM

Title: User-defined variable
Post by: gheppell on May 22, 2020, 01:33:16 PM
Hello. 

Please pardon this simple question, but I am wondering if I can define a simple custom variable that holds a string.

For context, I sometimes run a command that adds timezone info to some xmp tags.  If goes something like this.

exiftool -datecreated<${createdate}-07:00 -datetimeoriginal<${createdate}-07:00

There are actually 3 or 4 of these, so when I change the timezone info, I have to alter each part of the command individually.  I would like to set the first 3 characters of the time zone as a custom variable then have the commands reference it.  Something like

exiftool -mycustomstring="-06" -datecreated<${createdate}${mycustomstring}:00 -datetimeoriginal<${createdate}${mycustomstring}:00....etc for the other 3 or 4 of these that I do at once. 

Thank you
Title: Re: User-defined variable
Post by: StarGeek on May 22, 2020, 02:28:39 PM
I'd suggest adding a shortcut to your .ExifTool_config file. 

For your example tags, your shortcut would be something like
   MyXMPDates   => ['XMP:DateCreated','XMP:DateTimeOriginal'],

You would add this to the shortcut section of your config file.  If you don't already have a shortcut section, the entire thing would be
%Image::ExifTool::UserDefined::Shortcuts = (
   MyXMPDates   => ['XMP:DateCreated','XMP:DateTimeOriginal'],
);


Then your command to write to all the tags at once would be
exiftool "-MyXMPDates<${createdate}-07:00" /path/to/files/

See the example.config file (https://exiftool.org/config.html) for further details