merging metadata from duplicate images

Started by bungaman, January 27, 2024, 05:50:29 PM

Previous topic - Next topic

bungaman

There are a couple of different posts related to parts of this question, but I couldn't find an exact match.

I'm trying to merge dates, keywords, description, title, and GPS coordinates between two duplicate images - one of which is deemed primary. Let's say primary.jpg and duplicate.jpg are the names.

The other rules I'd like to follow are:
a) concatenate the keywords between primary.jpg and duplicate.jpg and remove duplicates in primary.jpg
b) for non-list tags (date, description, title, GPS), if the primary already has a tag then don't overwrite that tag in primary, just create new tags
c) for date, maintain an order of priority - 1) DateTimeOriginal 2) GPSDateTime 3) CreateDate
  => so if primary.jpg has a GPSDateTime, but no DateTimeOriginal then that would be overwritten by duplicate.jpg with a DateTimeOriginal value.
d) if there is Exif info about camera etc. it would be nice to preserve that.

To address a) above - these two commands seem to cover it;
exiftool -addtagsfromfile duplicate.jpg -keywords'+<keywords' primary.jpg
exiftool -sep "##" "-keywords<${keywords;NoDups}" primary.jpg

To address b) above - specifically description and title;
(is it better to use an IF condition OR to use the -wm cg option?)
exiftool -if "not $title" -addtagsfromfile duplicate.jpg -title primary.jpg
exiftool -if "not $description" -addtagsfromfile duplicate.jpg -description primary.jpg

To address b) dates and GPS, can someone point me in the right direction for those?


And, if some images have sidecars versus embedded tags, does that change any of the command formats?



Posts related to this (similar) topic:
https://exiftool.org/forum/index.php?topic=7827.0
Date consolidation with some hierarchy of priority:
https://exiftool.org/forum/index.php?topic=12325.0

Stargeek also has this post which seems pertinent as well for merging/syncing all the keyword fields:
https://exiftool.org/forum/index.php?topic=9208.0
(could that be used in the above context?)


StarGeek

Quote from: bungaman on January 27, 2024, 05:50:29 PMTo address a) above - these two commands seem to cover it;
exiftool -addtagsfromfile duplicate.jpg -keywords'+<keywords' primary.jpg
exiftool -sep "##" "-keywords<${keywords;NoDups}" primary.jpg

If you're using ver 12.64+, then you can combine the two with
exiftool -TagsFromFile @ -keywords -TagsFromFile duplicate.jpg -+keywords -api nodups primary.jpg
or
exiftool "-Keywords<Keywords" -TagsFromFile duplicate.jpg  -+keywords -api nodups primary.jpg

QuoteTo address b) above - specifically description and title;
(is it better to use an IF condition OR to use the -wm cg option?)
exiftool -if "not $title" -addtagsfromfile duplicate.jpg -title primary.jpg
exiftool -if "not $description" -addtagsfromfile duplicate.jpg -description primary.jpg

Both of these would completely overwrite the tags in the primary.jpg with the values from the duplicate.jpg.  The -AddTagsFromFile option only affects list type tags and for tags like Description function the same as -TagsFromFile.  It has also been depricated with the use of the -+TAG option used above.  It doesn't look like it's even in the docs anymore.

The best way to do this would be with -wm cg.  Using the -if option, especially with a lot of tags to check, would become unweildy and require the use of the -FileNum option.

QuoteTo address b) dates and GPS, can someone point me in the right direction for those?

I would think the above option with -wm cg would be best, unless you're trying to double check the values against each other.  For example, comparing the values of DateTimeOriginal from the original and the duplicate as well as comparing it against CreateDate and the GPS time stamps.


QuoteAnd, if some images have sidecars versus embedded tags, does that change any of the command formats?

That would mean you would have to duplicate an extra -TagsFromFile %f.xmp in the above cases and figure out the precedence as per Note #1 under the -TAG[+-^]=[VALUE] option.

QuoteStargeek also has this post which seems pertinent as well for merging/syncing all the keyword fields:
https://exiftool.org/forum/index.php?topic=9208.0
(could that be used in the above context?)

I haven't tested that user defined tag against some of the newer options used above, so I would keep with keeping it simple and copying each tag individually for the moment.  If I recall, there was a minor error in that config and I'm not sure if I updated that listing or not.
* 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).