How to Copy Multiple (Duplicate) tags into a single tag

Started by Greyfox, September 30, 2023, 08:35:03 PM

Previous topic - Next topic

Greyfox

As a result of a Face Detection function, images that contain multiple identified faces have the individual face names appear in multiple RegionsRegionListName tags.

I want to be able to copy all the names into a single tag IPTC:Keywords, with the names separated by commas.

ExifTool "-IPTC:Keywords<RegionsRegionListName" *.jpg copies only the first RegionsRegionsListName tag name.

Any help would be appreciated

Edit:
Ok I've found I can do that with
Exiftool "-IPTC:Keywords-<RegionsRegionListName" "-+IPTC:Keywords+<RegionsRegionListName" *.jpg

However that same format will not allow me to write the names from RegionsRegionListName into the Exif ImageDescription tag.

If I use
Exiftool "-IFD0:ImageDescription-<RegionsRegionListName" "-+IFD0:ImageDescription+<RegionsRegionListName" *.jpg

I get the Warning "Shift value for IFD0:ImageDescription is not a number", and the file is not updated
Perhaps that is because ImageDescription is not a list type tag

Is there another way to make that work?.



StarGeek

Quote from: Greyfox on September 30, 2023, 08:35:03 PMIf I use
Exiftool "-IFD0:ImageDescription-<RegionsRegionListName" "-+IFD0:ImageDescription+<RegionsRegionListName" *.jpg

I get the Warning "Shift value for IFD0:ImageDescription is not a number", and the file is not updated
Perhaps that is because ImageDescription is not a list type tag

Yes.  You can't update a simple string tag (ImageDescription) like you can with a list type tag.

I can't think of a way to easily remove the values of a list type tag from a string tag. It could be done, but at that point a user defined tag would be a better option. It would take the list tag, loop through all the values and do a RegEx replacement on each.  But this would also remove the same values if they occurred in the base value of ImageDescription.  For example, if you had region names of "Jane Doe" and "John Smith" and the description said "Jane Doe and John Smith's marriage ceremony", then you would end up with " and 's marriage ceremony Jane Doe, John Smith".

I would say the easiest option is to have some sort of separator phrase directly before the region list.  You could then remove everything after that phrase and replace it.

An example using "People in Image:" as the key phrase.  First ImageDescription is displayed with the -b (-binary) option so you can see the line feeds.
C:\>exiftool -all= -P -overwrite_original -E -ImageDescription="The 100th birthday party of Grandpa John.  Grandpa was born in the year 1923.&#x0a;&#x0a;People in Image: Grandpa John, Jane Doe" -Subject="Grandpa John" -Subject="Jane Doe" y:\!temp\Test4.jpg
    1 image files updated

C:\>exiftool -G1 -a -s -ImageDescription -b y:\!temp\Test4.jpg
The 100th birthday party of Grandpa John.  Grandpa was born in the year 1923.

People in Image: Grandpa John, Jane Doe
C:\>exiftool -G1 -a -s -Subject y:\!temp\Test4.jpg
[XMP-dc]        Subject                         : Grandpa John, Jane Doe

C:\>exiftool -P -overwrite_original -Subject+="Long lost cousin Jessica" y:\!temp\Test4.jpg
    1 image files updated

C:\>exiftool -P -overwrite_original "-ImageDescription<${ImageDescription;s/People in Image:.*//;}People in Image: $Subject" y:\!temp\Test4.jpg
    1 image files updated

C:\>exiftool -G1 -a -s -ImageDescription -b y:\!temp\Test4.jpg
The 100th birthday party of Grandpa John.  Grandpa was born in the year 1923.

People in Image: Grandpa John, Jane Doe, Long lost cousin Jessica
"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

Greyfox

Quote from: StarGeek on October 01, 2023, 12:10:06 PMYes.  You can't update a simple string tag (ImageDescription) like you can with a list type tag.

I can't think of a way to easily remove the values of a list type tag from a string tag. It could be done, but at that point a user defined tag would be a better option. It would take the list tag, loop through all the values and do a RegEx replacement on each.  But this would also remove the same values if they occurred in the base value of ImageDescription.  For example, if you had region names of "Jane Doe" and "John Smith" and the description said "Jane Doe and John Smith's marriage ceremony", then you would end up with " and 's marriage ceremony Jane Doe, John Smith".

I would say the easiest option is to have some sort of separator phrase directly before the region list.  You could then remove everything after that phrase and replace it.

An example using "People in Image:" as the key phrase.  First ImageDescription is displayed with the -b (-binary) option so you can see the line feeds.
C:\>exiftool -all= -P -overwrite_original -E -ImageDescription="The 100th birthday party of Grandpa John.  Grandpa was born in the year 1923.&#x0a;&#x0a;People in Image: Grandpa John, Jane Doe" -Subject="Grandpa John" -Subject="Jane Doe" y:\!temp\Test4.jpg
    1 image files updated

C:\>exiftool -G1 -a -s -ImageDescription -b y:\!temp\Test4.jpg
The 100th birthday party of Grandpa John.  Grandpa was born in the year 1923.

People in Image: Grandpa John, Jane Doe
C:\>exiftool -G1 -a -s -Subject y:\!temp\Test4.jpg
[XMP-dc]        Subject                         : Grandpa John, Jane Doe

C:\>exiftool -P -overwrite_original -Subject+="Long lost cousin Jessica" y:\!temp\Test4.jpg
    1 image files updated

C:\>exiftool -P -overwrite_original "-ImageDescription<${ImageDescription;s/People in Image:.*//;}People in Image: $Subject" y:\!temp\Test4.jpg
    1 image files updated

C:\>exiftool -G1 -a -s -ImageDescription -b y:\!temp\Test4.jpg
The 100th birthday party of Grandpa John.  Grandpa was born in the year 1923.

People in Image: Grandpa John, Jane Doe, Long lost cousin Jessica

Many thanks StarGeek. That's given me something to work with.