Is it possible to add keywords from regionpersondisplayname avoiding duplicates?

Started by xNemo, June 28, 2023, 07:50:21 PM

Previous topic - Next topic

xNemo

I use an app for face recognition and it provides some metadata. I figured out how to add names from regionpersondisplayname tag to xmp keywords.

This is the command I use and it works fine:

exiftool "-xmp-dc:subject+<regionpersondisplayname" "d:\folder\*.jpg"

Is there a way to add the names to keywords avoiding duplicates in the keywords? I looked through this section of the FAQ https://exiftool.org/faq.html#Q17 (prevent duplication when adding new items), but I can't figure out how to apply it in my case. Could anyone help me please?

Phil Harvey

Yes, this is a bit tricky.  Here is the command:

exiftool "-xmp-dc:subject-<regionpersondisplayname" "-+xmp-dc:subject+<regionpersondisplayname" -ext jpg "d:\folder"

You remove the keywords you are adding from the existing keywords in the file.  The trick is that you need to add a "+" before the destination tag name in the second argument to prevent overriding the first argument.  Alternatively, this is the old way to do it:

exiftool -addtagsfromfile @ "-xmp-dc:subject-<regionpersondisplayname" "-xmp-dc:subject+<regionpersondisplayname" -ext jpg "d:\folder"

... but the -addTagsFromFile option is now undocumented, but still works for backward compatibility.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

xNemo

Thank you so much! I try to use this command and it really removes duplicates, but doesn't add keywords.

exiftool "-xmp-dc:subject-<regionpersondisplayname" "-+xmp-dc:subject+<regionpersondisplayname" -ext jpg "d:\folder"

I could remove the duplicates with it and run it just like this to add the keywords that were removed
exiftool "-xmp-dc:subject-<regionpersondisplayname" -ext jpg "d:\folder"
exiftool "-xmp-dc:subject+<regionpersondisplayname" -ext jpg "d:\folder"

But I'm sure that it can be done in one line. Is there something I'm missing?


StarGeek

What version of exiftool are you using?
exiftool -ver

The -+ format requires 12.59 (I think) or higher.  Otherwise use the -AddTagsFromFile @ version of the command Phil listed.

C:\>exiftool -G1 -a -s -Subject -RegionPersonDisplayName y:\!temp\Test4.jpg
[XMP-dc]        Subject                         : John Smith
[XMP-MP]        RegionPersonDisplayName         : John Smith, Jane Doe

C:\>exiftool -P -overwrite_original -addtagsfromfile @ "-xmp-dc:Subject-<RegionPersonDisplayName" "-xmp-dc:Subject+<RegionPersonDisplayName" y:\!temp\Test4.jpg
    1 image files updated

C:\>exiftool -G1 -a -s -Subject -regionpersondisplayname y:\!temp\Test4.jpg
[XMP-dc]        Subject                         : John Smith, Jane Doe
[XMP-MP]        RegionPersonDisplayName         : John Smith, Jane Doe
* 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).

xNemo

Yes, you were right, I had 12.57. I have the latest version now and checked it. The old notation works like a charm, but the new one still won't work. I guess I'll stick to the old one

Thanks, both of you, you're so helpful! 🙏