ExifTool Forum

ExifTool => Newbies => Topic started by: Matthx on January 12, 2021, 09:23:39 AM

Title: Append within tag
Post by: Matthx on January 12, 2021, 09:23:39 AM
Hello,

I understand I can append text to a field using exiftool, however is it possible to append text at a certain point in a field.

For instance, the caption field reads:

CARDIFF, WALES - MARCH 1: XXX March 1, 2020, in Cardiff, Wales.

And I would like to insert text at the point where XXX is

I initially thought it might be possible to 'offset' the start to account for the characters before (city and date) but this text will change from picture to picture.

Is there possibly a way of substituting matched text?

Thanks in advance,

Matt
Title: Re: Append within tag
Post by: StarGeek on January 12, 2021, 10:30:52 AM
This can be done with the Advanced formatting feature (https://exiftool.org/exiftool_pod.html#Advanced-formatting-feature), which is basically just a bit of Perl code inside the tag name.  It is most commonly done with a RegEx (Regular Expression) substitution.  There is this example (https://exiftool.org/exiftool_pod.html#exiftool--Description-FileName-s-.-.-dir) in the docs and it is one of the most common questions on this forum.  You can find more examples with this Google search (https://www.google.com/search?q=site%3Aexiftool.org+regex+%22s%2F%22).

Using your example your command would be along these lines
exiftool "-Description<${Description;s/: XXX/: new word XXX/}" file.jpg
Title: Re: Append within tag
Post by: Matthx on January 12, 2021, 01:41:21 PM
That is incredibly helpful. Thank you!