"No writable tags set" when tag is empty - copying/merging tags within files

Started by RSI, September 26, 2019, 02:09:43 PM

Previous topic - Next topic

RSI

Hello altogether,

I just wrote my first (almost) working exiftool batch script and after I sorted out every "normal" mistake I made and everything worked fine for one test image the final test with several photos left me puzzled. Can someone please give me a hint what mistake I made? The script is supposed to combine metadata from several iptc fields with fixed strings and write this back as an iptc caption. As last step it deletes iptc headline because it is now included in caption.

Some images won't have all of the used fields populated (especially caption may be empty sometimes). In this case it should just ignore it or handle it like an empty string. Based on the documentation I think this is the default behavior. But it seems that every file where a caption (or headline or copyright notice or any other used field) is missing isn't processed correctly.

My script, which is executed on Win 10 in cmd with one parameter (directory path):
echo off
:: doesn't fix anything important, but shows special characters correctly on the command line as this batchfile is coded in UTF-8
chcp 65001

:: Step 1: Add headline after caption, then append Strings (including special characters), than append Copyright
exiftool -overwrite_original -tagsfromfile %%d%%f.jpg -ext jpg -h "-iptc:Caption-Abstract < ${iptc:Caption-Abstract}$/$/${iptc:Headline}$/$/Weitere Bilder im Album und auf https://shop.rseidelimagery.de .$/$/Teilt & kommentiert gerne und markiert Freunde im Bild. Downloads und Prints zur eigenen Verwendung im Webshop. Kontaktier mich f&uuml;r Bilder oder Verwendungszwecke, die im Shop nicht erh&auml;ltlich sind.$/${iptc:CopyrightNotice}" %1

:: Step 2: Keyword processing is separated to avoid problems with umlauts or other special characters (Because of -h in the upper command special characters get translated to HTML entities when keywords are read, but they don't get translated back when exiftool appends them to the caption.)
exiftool -overwrite_original -tagsfromfile %%d%%f.jpg -ext jpg "-iptc:Caption-Abstract < ${iptc:Caption-Abstract}$/$/#${xmp:subject;s/ //g;s/&(?![a-zA-Z0-9#]{2,7};{1})//g;s/,/ #/g}$/$/ID: ${FileName;s/^[0-9]{6}_//;s/_[0-9a-zA-Z._\- ]*$//}" "-iptc:Headline=" %1

pause


For every file where some used tag/field is not already filled I get an error message and the most important part of my script is skipped:
Warning: [minor] Tag 'iptc:Caption-Abstract' not defined - J:/4.1 - Exporte/Facebook/ETEST/190922_RS-216193_NIK_0125_FB.jpg
Warning: No writable tags set from J:/4.1 - Exporte/Facebook/ETEST/190922_RS-216193_NIK_0125_FB.jpg
...
    1 directories scanned
    5 image files updated
  113 image files unchanged
Warning: [minor] Tag 'iptc:Caption-Abstract' not defined - J:/4.1 - Exporte/Facebook/ETEST/190922_RS-216193_NIK_0125_FB.jpg
Warning: No writable tags set from J:/4.1 - Exporte/Facebook/ETEST/190922_RS-216193_NIK_0125_FB.jpg
...
    1 directories scanned
  118 image files updated

StarGeek

Quote from: RSI on September 26, 2019, 02:09:43 PM
Some images won't have all of the used fields populated (especially caption may be empty sometimes). In this case it should just ignore it or handle it like an empty string. Based on the documentation I think this is the default behavior.

The default behavior is to fail if a tag does not exist, which is why you get the "No writable tags set" error.  To force it to work you need the -m (ignoreMinorErrors) option.  Or you can use the -f (ForcePrint) option and the missing tags will be replaced by a dash.  You can change that by adding -api MissingTagValue= to set a different default character.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

RSI

Quote from: StarGeek on September 26, 2019, 03:23:16 PMThe default behavior is to fail if a tag does not exist, which is why you get the "No writable tags set" error.  To force it to work you need the -m (ignoreMinorErrors) option.

Oh. I must have gotten something wrong in the documentation.
Ignore Errors flags always feel a little like cheating :D But it works now. Thank you!