Combining strings and tag values

Started by Bona Sierra, June 28, 2024, 10:25:22 AM

Previous topic - Next topic

Bona Sierra

Hi,
I want to combine the filename and a string as a new tag value, e.g.

exiftool -P -overwrite_original -UserComment="some text" "-UserComment+<<${filename;s/\.[^.]*$//}" FILES

The result is:
Warning: No writable tags set from FILES

The problems seems to be the "-UserComment+<<${filename;s/\.[^.]*$//}", but I have no idea how it can work.
Windows 11 Pro

StarGeek

You can't both assign a value and copy a tag value separately to the same tag in one command. From note #1 under the -TAG[+-^]=[VALUE] option
QuoteMany tag values may be assigned in a single command. If two assignments affect the same tag, the latter takes precedence

So in your command, -UserComment="some text" would be ignored.

The correct command would be found under the -TagsFromFile option
QuoteAn extension of the redirection feature allows strings involving tag names to be used on the right hand side of the < symbol with the syntax "'-DSTTAG<STR'", where tag names in STR are prefixed with a $ symbol.

Also, you can use the BaseName tag instead of the Filename to remove the extension

Here's an example using multiple static texts and multiple tags
exiftool -P -overwrite_original "-UserComment<some text $Basename some more text $Model" /path/to/files/
* 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).

Bona Sierra

Hi StarGeek,

thank you for this advice, I will report my results later today after todays european championships soccer games.

And sorry for the "<<" typo. I hope it didn't cause any confusion.  ;)

Btw: I thought it should be possible to add another string to a tag within one command line using the '+=' or '+<' operator.

Bona
Windows 11 Pro

StarGeek

Quote from: Bona Sierra on June 30, 2024, 12:08:39 PMBtw: I thought it should be possible to add another string to a tag within one command line using the '+=' or '+<' operator.

These can only be used in a few situations
  • Add/remove from a list type tag
  • Shift a Date/Time tag
  • Shift a simple number tag
  • Conditionally remove a value

For +=, from the docs on the -TAG[+-^]=[VALUE] option
Quote+= and -= are used to add or remove existing entries from a list, or to shift date/time values (see Image::ExifTool::Shift.pl and note 6 below for more details). += may also be used to increment numerical values (or decrement if VALUE is negative), and -= may be used to conditionally delete or replace a tag (see "WRITING EXAMPLES" for examples).

For +<, from the docs on the -TagsFromFile option
Quote+<= or -<= may also be used to add or delete specific list entries, or to shift date/time values.
* 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).

Bona Sierra

thanks for the explanation.

Now I understood, this means none of the JPEG and EXIF tags, but some of the IPTC and many of XMP tags which are list type tags, as indicated by the '+' sign in the tag names list.

good to know  :)
Windows 11 Pro