ExifTool Forum

ExifTool => Newbies => Topic started by: demianill on January 31, 2020, 10:12:32 AM

Title: Another question about Concatenation / Merging fields
Post by: demianill on January 31, 2020, 10:12:32 AM
Hi Phil and friends!

Once more, please, forgive my poor English.

Once again, I have a question for which I have not yet succeeded. I researched a lot here on the forum before posting, but the answers I found were not exactly what I was looking for.
As I am not an IT guy, just a photographer, I have some difficulty.

Let's get to the problem: I have to copy and unify in a single field information that is distributed in several fields, such as FixtureIdentifier, ByLine, ByLineTitle, SpecialInstructions (these fields are being used improperly, with information that does not relate to the type of content for which they were created) and two Userdefined fields, already defined (and functional) in my config file.

I plan on using the Caption-Abstract field as the final destination for this concatenated information, because it supports a large number of characters.

I used the following command to check the contents of two fields:

exiftool -config DWS005.config -s -G1 -IPTC206 -Caption-Abstract /Users/demianill/Desktop/_JPG/IMG47039.jpg


[IPTC]          IPTC206                         : Essa imagem só pode ser solicitada mediante negogiação prévia com a área de Patrocínio. Além disso, essa imagem possui data de expiração, não podendo ser utilizada após 31/12/2020.
[IPTC]          Caption-Abstract                : Atleta do Time Juvenil , Eduardo Kazishovsk


In this example, I would like to add (concatenate) the current content of the IPTC206 field to the Caption-Abstract field.

From the examples I found on the forum, I thought that the command

exiftool -config DWS005.config '-Caption-Abstract+<IPTC206' IMG47039.jpg


could merge the two fields, but I got an error message:

Warning: Shift value for IPTC: Caption-Abstract is not a number - IMG47039.jpg
Warning: No writable tags set from IMG47039.jpg
    0 image files updated
    1 image files unchanged


   
So I tried the command (without the + sign)

exiftool -config DWS005.config '-Caption-Abstract<IPTC206' IMG47039.jpg


    1 image files updated

Naturally, as expected, there was no concatenation, only substitution, resulting in the loss of the original content of the -Caption-Abstract field:

exiftool -config DWS005.config -s -G1 -IPTC206 -Description /Users/demianill/Desktop/_JPG/IMG47039.jpg


[IPTC]          IPTC206                         : Essa imagem só pode ser solicitada mediante negogiação prévia com a área de Patrocínio. Além disso, essa imagem possui data de expiração, não podendo ser utilizada após 31/12/2020.
[IPTC]          Caption-Abstract                : Essa imagem só pode ser solicitada mediante negogiação prévia com a área de Patrocínio. Além disso, essa imagem possui data de expiração, não podendo ser utilizada após 31/12/2020.

(after all, I would like to obtain Atleta do Time Juvenil , Eduardo Kazishovsk Essa imagem só pode ser solicitada mediante negogiação prévia com a área de Patrocínio. Além disso, essa imagem possui data de expiração, não podendo ser utilizada após 31/12/2020 )


How to make a concatenation? Note that in this test example I tried to concatenate only two fields, but my goal is to concatenate several fields.
How should this be done? In one go or in smaller groups?
Please, could you post an example of concatenation merging several fields ? (FixtureIdentifier, ByLine, ByLineTitle, SpecialInstructions, userdefined fields)

I really appreciate your help!

Forgive the inconvenience, as this probably must be an elementary doubt, but for me it is difficult to solve it myself!

Big hug from Demian.

Title: Re: Another question about Concatenation / Merging fields
Post by: greybeard on January 31, 2020, 11:06:13 AM
This works with my file (don't have the IPTC206 so I used camera make)

exiftool '-caption-abstract<$caption-abstract $make' imagefile.jpg
Title: Re: Another question about Concatenation / Merging fields
Post by: StarGeek on January 31, 2020, 11:12:46 AM
To add one tag to the end of another, you would do something like this:
exiftool -config DWS005.config '-Caption-Abstract<$Caption-Abstract $IPTC206' IMG47039.jpg

Quote from: demianill on January 31, 2020, 10:12:32 AMFrom the examples I found on the forum, I thought that the command

exiftool -config DWS005.config '-Caption-Abstract+<IPTC206' IMG47039.jpg

The +< is used to add items to list type tags, such as Keywords, without overwriting any previous keywords.  It's not used with simple string tags.
   
QuoteHow to make a concatenation? Note that in this test example I tried to concatenate only two fields, but my goal is to concatenate several fields.
How should this be done? In one go or in smaller groups?

It can be done all in one shot.  Just format them how you want and copy them to the target tag.  Take note that if you have characters at the end of a tag that you need to put braces around the tag name so exiftool doesn't think the tag name is longer than you mean it to be.  For example:
exiftool '-Caption-Abstract<${ISO}_$Make' <FileOrDir>
In this case, ISO has an underscore following it.  To show exiftool that the tag is ISO and not ISO_, you need braces to separate the tag name from the underscore.
Title: Re: Another question about Concatenation / Merging fields
Post by: demianill on February 03, 2020, 09:17:24 AM
Dear greybeard, Dear StarGeek,

Thank you very, very, very much !

I figured out (after many tries) that for images where some field is empty, I got an error telling me that field is not defined.
See the example below (I tried other fields, instead -Caption-Abstract, the field -DocumentNotes is very useful for us, too).

exiftool -config DWS005.config '-DocumentNotes<$DocumentNotes $ObjectName $LocalCaption $SpecialInstructions $By-line $IPTC206 $IPTC208 $FixtureIdentifier $JobID' IMG47039.jpg

the answer was:

Warning: [minor] Tag 'DocumentNotes' not defined - IMG47039.jpg
Warning: No writable tags set from IMG47039.jpg
    0 image files updated
    1 image files unchanged


As I said, after many tries I decided to wrote some text to DocumentNotes field.
So, the error remains, because the field IPTC206 was empty for this image.
I wrote some text in IPTC206, then:

exiftool -config DWS005.config '-DocumentNotes<$DocumentNotes $ObjectName $LocalCaption $SpecialInstructions $By-line $IPTC206 $IPTC208 $FixtureIdentifier $JobID' IMG47039.jpg
    1 image files updated



I did this operation im some images in my directory for tests (I didn't applied in the real directory yet).

The DocumentNotes field seems to be more suited to our needs, but it is really empty in 95% of the images. Any suggestions to perform this concatenation/merging operation, without having to fill DocumentNotes with any information in advance?

Once again, thank you very much for your precious help!
Title: Re: Another question about Concatenation / Merging fields
Post by: Phil Harvey on February 03, 2020, 09:31:03 AM
There are three ways around this.  Two of the methods are mentioned in the -p option documentation:

            If a specified tag does not exist, a minor warning is issued and
            the line with the missing tag is not printed.  However, the -f
            option may be used to set the value of missing tags to '-' (but
            this may be configured via the MissingTagValue API option), or the
            -m option may be used to ignore minor warnings and leave the
            missing values empty.

And the third is to have a fallback value that you write when DocumentNotes doesn't exist.  For example:

exiftool -config DWS005.config '-DocumentNotes< SOME_DEFAULT_STRING_TO_USE_WHEN_DOCUMENTNOTES_ISNT_AVAILABLE $ObjectName $LocalCaption $SpecialInstructions $By-line $IPTC206 $IPTC208 $FixtureIdentifier $JobID' '-DocumentNotes<$DocumentNotes $ObjectName $LocalCaption $SpecialInstructions $By-line $IPTC206 $IPTC208 $FixtureIdentifier $JobID' IMG47039.jpg

The second copy argument will override the earlier one if DocumentNotes is available.

- Phil
Title: Re: Another question about Concatenation / Merging fields
Post by: demianill on February 03, 2020, 01:56:14 PM
Quote from: Phil Harvey on February 03, 2020, 09:31:03 AM
There are three ways around this.  Two of the methods are mentioned in the -p option documentation:

            If a specified tag does not exist, a minor warning is issued and
            the line with the missing tag is not printed.  However, the -f
            option may be used to set the value of missing tags to '-' (but
            this may be configured via the MissingTagValue API option), or the
            -m option may be used to ignore minor warnings and leave the
            missing values empty.

And the third is to have a fallback value that you write when DocumentNotes doesn't exist.  For example:

exiftool -config DWS005.config '-DocumentNotes< SOME_DEFAULT_STRING_TO_USE_WHEN_DOCUMENTNOTES_ISNT_AVAILABLE $ObjectName $LocalCaption $SpecialInstructions $By-line $IPTC206 $IPTC208 $FixtureIdentifier $JobID' '-DocumentNotes<$DocumentNotes $ObjectName $LocalCaption $SpecialInstructions $By-line $IPTC206 $IPTC208 $FixtureIdentifier $JobID' IMG47039.jpg

The second copy argument will override the earlier one if DocumentNotes is available.

- Phil


Phil, you are great !
Thank you VERY much !

Demian.