Author Topic: Create IPTC tag if it does not exist  (Read 3193 times)

michael.haar

  • Newbie
  • *
  • Posts: 4
Create IPTC tag if it does not exist
« on: January 14, 2014, 09:08:30 AM »
Hi there,
I'm using ExifTool 8.5 and I'm trying to append some information to the 'caption-abstract' tag using this command:

exiftool -IPTC:Caption-Abstract<$caption-abstract ${caption} -charset Latin -overwrite_original /data/images/$imageFilename

This works great for images that already have the 'caption-abstract' tag but ExifTool only gives a warning ("No writable tags") if the image does not have the 'caption-abstract' tag before I try to append something.

How can I make ExifTool to create the tag if it does not exist?

Sorry if this is a dumb question but I was unable to figure it out.
Thanks in advance!
Michael


Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 16883
    • ExifTool Home Page
Re: Create IPTC tag if it does not exist
« Reply #1 on: January 14, 2014, 09:21:43 AM »
Hi Michael,

There are 2 ways:

1) Use either -f or -m.  From the application 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.


2) Assign the value to the caption-abstract in the same command, before the append:

exiftool "-caption-abstract=TEST1" "-caption-abstract<$caption-abstract TEST2" ...

In this example, the Caption-Abstract will be set to TEST1 if it doesn't already exist.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

michael.haar

  • Newbie
  • *
  • Posts: 4
Re: Create IPTC tag if it does not exist
« Reply #2 on: January 14, 2014, 09:52:00 AM »
Hi Phil,

thanks for your fast response. Unfortunately I'm still unable to get the desired result.
-f or -m does not change anything:
exiftool -f "-caption-abstract<$caption-abstract TEST2" image.jpg
still says "No writable tags found".

This command:
exiftool "-caption-abstract=TEST2" "-caption-abstract<$caption-abstract TEST2" image.jpg
sets "caption-abstract" to "TEST2" if does not exist BUT it replaces "caption-abstract" with "TEST2" if it was present instead of appending "TEST2" to the existing "caption-abstract".

Please help!
Regards,
Michael

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 16883
    • ExifTool Home Page
Re: Create IPTC tag if it does not exist
« Reply #3 on: January 14, 2014, 10:30:24 AM »
Right.  I should have suggested that you upgrade to a more recent version.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

michael.haar

  • Newbie
  • *
  • Posts: 4
Re: Create IPTC tag if it does not exist
« Reply #4 on: January 14, 2014, 11:06:43 AM »
Hi Phil,

I updated to version 9.46 but it is still not working.
This command:
exiftool "-caption-abstract=TEST2" "-caption-abstract<$caption-abstract TEST2" image.jpg
still always sets "caption-abstract" to "TEST2" regardless of the tag being present when I execute the command or not.

But I want ExifTool to set "caption-abstract" to "TEST2" if the image does not have this tag and append "TEST2" to the value of the tag if it is present.

Any other idea?
Regards,
Michael

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 16883
    • ExifTool Home Page
Re: Create IPTC tag if it does not exist
« Reply #5 on: January 14, 2014, 11:20:23 AM »
Hi Michael,

I'm on a Mac so I use single quotes instead of double quotes:

Code: [Select]
> exiftool -ver
9.46

> exiftool -all= a.jpg
    1 image files updated

> exiftool '-caption-abstract=TEST1' '-caption-abstract<$caption-abstract TEST2' a.jpg
Warning: [minor] Tag 'caption-abstract' not defined - a.jpg
Warning: No writable tags set from a.jpg
    1 image files updated

> exiftool -caption-abstract a.jpg
Caption-Abstract                : TEST1

> exiftool '-caption-abstract=TEST1' '-caption-abstract<$caption-abstract TEST2' a.jpg
    1 image files updated

> exiftool -caption-abstract a.jpg
Caption-Abstract                : TEST1 TEST2

> exiftool -caption-abstract="something else" a.jpg
    1 image files updated

> exiftool '-caption-abstract=TEST1' '-caption-abstract<$caption-abstract TEST2' a.jpg
    1 image files updated

> exiftool -caption-abstract a.jpg
Caption-Abstract                : something else TEST2

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

michael.haar

  • Newbie
  • *
  • Posts: 4
Re: Create IPTC tag if it does not exist
« Reply #6 on: January 15, 2014, 02:52:54 AM »
Phil,
I must have done something wrong yesterday: today I followed your instructions and it works now!
Thanks a lot!
Regards,
Michael