Reformatting jpg metadata from xmps with similar names in batch

Started by vilkoski, November 16, 2024, 03:31:48 AM

Previous topic - Next topic

vilkoski

Hi.

I would need to read [RegionInfo] (which includes names of persons added in LrC People View - exiftool -s gives me this) in directory(ies) of xmp files and then replace [Caption] in corresponding jpeg files combined with some other info (added handwritten description of the event, original date (dd.mm.yyy), city, country) and finally set some required tags like category, city and location.

(I would also like to place the [RegionInfo] to [PersonShown] for better reusability in the future because LrC puts the People View info to [RegionInfo] and [keywordTagsPerson] in the original catalog but after import the names can only be found among [Keywords] because People-attribute of the Keywords is lost outside original catalog.)

XMP-files have names from camera like DSC5057.xmp and corresponding jpegs have names like DSC5057-Edit.jpg where depending on camera 7-8 first characters are the same as in the corresponding xmp.

I could try to read the documentation for days and still probably fail to get a command to do this if it is even doable.
I'm probably all over the place here and wrong about -ext %d%f-Edit.JPG but I'm thinking this is something that can be done?
Any help getting this thing closer to target highly appreciated.
 

exiftool -tagsFromFile -ext XMP "-XMP-ipctExt:PersonShown<xmp:RegionInfo" "-Caption-Abstract=XMP-ipctExt:PersonShown 'Hometeam-Awayteam match' %dd.%mm.%yyyy datetimecreated Caption-Abstract, CreatorCity" -category=SPO -city=$CreatorCity -Country-PrimaryLocationName=Finland -ext %d%f-Edit.JPG

StarGeek

To clarify, you want to take data from DSC5057.xmp and write it to DSC5057-Edit.jpg.

The filename following the -TagsFromFile option will always be the file you are copying from. In this case, you want to remove the "-edit" from the name of the JPEG file. This will use the % variables that are documented under the "Advanced features" section of the -w (-TextOut) option.

The %d variable contains the directory name, including the trailing slash. Assuming the XMP files are in the same directory as the JPEGs, no editing is needed.

The %f variable contains the base name of the file and doesn't include the extension DSC5057-Edit. To remove characters from the end of that, a negative sign is added %-f. The number of characters to remove is given by adding a dot and the number %-.5f.

Adding in the XMP extension, the resulting -TagsFromFile part will look like this
-TagsFromFile %d%-.5f.xmp

You don't want to reprocess the XMP, i.e. copy the data from the XMP files back onto itself, so the --ext (--extension) option (two dashes) is used to prevent this
--ext XMP

The percent variables that are used with formatting the date have to either be part of the -d (-dateFormat) option or as part of teh DateFmt helper function. The first one affects all date/time tags, so I'll use the helper function just in case you decide to add more to the command later.

"datetimecreated" isn't the name of a tag. Since your copying from an XMP file, the most likely tag to exist will be the DateCreated, as that corresponds to the EXIF:DateTimeOriginal tag. I would suggest double-checking all the date/time tags in the XMP sidecar file with this command and replace it if necessary
exiftool -time:all -G1 -a -s file.jpg

RegionInfo isn't the tag you want to copy from. That is a complex-structured tag (see the Structured Information page) that includes multiple sub-tags. The correct sub-tag to use would be RegionName.

PersonShown isn't a tag. The correct name is PersonInImage.

Caption-Abstract is an IPTC tag and cannot exist in an XMP sidecar. The corresponding location in XMP is Description, so that has been changed in the copy.

Try this command on some test files to see if it works correctly for you
exiftool --ext XMP -TagsFromFile %d%-.5f.xmp "-PersonInImage<RegionName" "-Caption-Abstract=$RegionName 'Hometeam-Awayteam match' ${DateCreated;DateFmt('%dd.%mm.%yyyy')} $Description, $CreatorCity" -category=SPO -city=CreatorCity -Country-PrimaryLocationName=Finland /path/to/files/

You are copying data from the XMP tags in the sidecar file into the IPTC IIM tags in the edited JPEG. The one thing I would suggest is to drop the IPTC tags and instead write to the XMP tags. That way you don't have to worry about syncing between IPTC and XMP tags. That command would be
exiftool --ext XMP -TagsFromFile %d%-.5f.xmp "-PersonInImage<RegionName" "-Description=$RegionName 'Hometeam-Awayteam match' ${DateCreated;DateFmt('%dd.%mm.%yyyy')} $Description, $CreatorCity" -XMP:category=SPO -XMP:city=CreatorCity -Country=Finland /path/to/files/
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

vilkoski

Ok - thanks a lot StarGeek for giving such a detailed explanation/answer.

I will give this a try and see if I need some more tweaking before starting to process my full archive.