Hi,
For the past several days I have been trying to make my expanded keywords work, but even though I read a lot of threads and FAQs I must be missing something.
Here's the simple problem: I have various different cameras that produce some of the same but also some unique tags in their metadata.
I need to take some of these tags and turn them into keywords so I can use them for simple filtering in downstream apps that don't understand some of the metadata. Some of the tags might be missing between models or even firmware releases.
My simple though was to add any that exist onto the keywords list dynamically by using +<
Here is my sample code:
exiftool -r -F -progress -sep ", " -o "${processdir}"'/NODATE/'\
'-FileCreateDate<FileCreateDate'\
'-FileCreateDate<CreateDate'\
'-filename<P_${FileName}'\
'-directory<'"${processdir}"'/${FileCreateDate;DateFmt("%Y")}/${FileCreateDate;DateFmt("%Y%m%d")}'\
'-directory<'"${processdir}"'/${CreateDate;DateFmt("%Y")}/${CreateDate;DateFmt("%Y%m%d")}'\
"${artist}"\
"${author}"\
"${xmpcopyright}"\
'-Keywords<Camera: ${Model;s/\s/_/g;}'\
'-Keywords<Camera: ${Model;s/\s/_/g;}_${CameraSerialNumber;$_=substr($_,-4);}'\
'-Keywords+<Software: ${Software;}'\
'-Keywords+<AutoRotation: ${AutoRotation;}'\
'-Keywords+<Orientation: ${Orientation;}'\
'-Keywords+<SceneCaptureType: ${SceneCaptureType;}'\
'-Keywords+<ProTune: ${ProTune;}'\
'-Keywords+<Sharpness: ${Sharpness;}'\
'-Keywords+<MeteringMode: ${MeteringMode;}'\
'-Keywords+<GainControl: ${GainControl;}'\
'-Keywords+<Contrast: ${Contrast;}'\
'-Keywords+<Saturation: ${Saturation;}'\
'-Keywords+<WhiteBalance: ${WhiteBalance;}'\
'-Keywords+<HDRSetting: ${HDRSetting;}'\
'-Subject<Keywords'\
-api 'Filter=s/HERO10 Black/GoPro_Hero10/g;'\
's/HERO9 Black/GoPro_Hero9/g;'\
's/HERO8 Black/GoPro_Hero8/g'\
"${importdir}"
importdir and processor as well as a few copyright strings are script variables. This is used on MacOS and with zsh.
My impression was that +< should be adding to the list of keywords. Any tag that missing from that list would therefore simply not product the keyword.
However when I run this keywords only ever has the very last keyword in.
I know I can assemble one large string with all keywords and the proper separator, but then the number of combinations necessary to account for missing tags becomes prohibitive.
The very first Camera keyword works great by itself. With serial number if it exists, without if not, but even one additional keyword +< will also override the camera keyword.
Must be missing something simple here. Thank you!
FAQ #17 (https://exiftool.org/faq.html#Q17)
Note there is a complication when copying multiple tags to a single list tag: Here, any assignment to a tag overrides earlier assignments to the same tag in the command.
...
Alternatively, the -addTagsFromFile option may be used to accumulate items when copying from multiple tags
See also Note #5 under the -TagsFromFile option (https://exiftool.org/exiftool_pod.html#tagsFromFile-SRCFILE-or-FMT).
This has always been a bit confusing.
The += (and +<) operators add to the list items that are pre-existing in the file. Simply using = adds to the list of new values you are writing, but < won't add to the new values unless you use the -addTagsFromFile option.
- Phil
Quote from: Phil Harvey on February 10, 2022, 01:59:52 PM
This has always been a bit confusing.
The += (and +<) operators add to the list items that are pre-existing in the file. Simply using = adds to the list of new values you are writing, but < won't add to the new values unless you use the -addTagsFromFile option.
- Phil
Thank you both! I am still not entirely clear about using
< vs
+<When I add
-addTagsFromFile @ I can assemble the list from above but also the two variants from my camera tag get both added even though I am using
< for the two Camera variants (trying to get the one with serial number when available) and all other keywords with
+<.
The "+" indicates you want to add to the values existing in the file. If you use it on any assignment to a list-type tag, then existing list values already in the original file will be preserved. It has nothing to do with the list of new values that you are accumulating for writing to the file.
This is mentioned in FAQ 17 (https://exiftool.org/faq.html#Q17), but you need to think about it to understand the implications.
- Phil