Rename person

Started by rubpa, January 22, 2014, 12:36:43 PM

Previous topic - Next topic

rubpa

Hello!

I use Picasa to face tag my photos. Recently I renamed a person from, say, nameX to nameY. Picasa being Picasa does use nameY on newly tagged photos but the xmp inside the old photos is nameX only. I would like to update these photos with nameY.

I could use -regionname-=nameX & -regionname+=nameY but I realized that for photos with multiple people, this could change the order of names and hence could affect the mapping to other region tags. Am I correct here? I did not try this option.

However, this is what I tried on some sample files after reading a lot about exiftool (really powerful options I must say)

  • exiftool -o %f.xmp *.JPG - created xmp tag file for all image files
  • used an editor/script to replace all nameX with nameY
  • exiftool -if '$regionname =~ /nameX/i' -tagsfromfile %f.xmp -regionname *.JPG

This worked fine. But it is a multi-step process. I strongly feel I could achieve this in a single command but could not figure it out. Please help if it's possible to do this in a single step!

Phil Harvey

One way to do this would be by filtering the RegionInfo structure:

exiftool '-regioninfo<${regioninfo;s/Name=nameX\b/Name=nameY/}' -ext jpg .

But I don't think that your first idea should change the order.  See here for notes about this.

- 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 ($).

rubpa

Thanks! Can you help me understand this more? What is the regioninfo structure? It does not appear to be a tag. How can I view this structure?

edit: I'll see the link in your post and get back.

mrbrahman

Quote from: Phil Harvey on January 22, 2014, 12:42:48 PM
But I don't think that your first idea should change the order. 

Indeed! I tried

exiftool -xmp:regionname-=nameX -xmp:regionname+=nameY file.jpg

And it it change the nameX which was the third of the four names in the XMP.

Thanks Phil for a really great tool!

mcwieger

#4
Hi all, I had a similar use case, but for person display name. Tried this for my collection and that worked:

exiftool -xmp:regionpersondisplayname-=NameX -xmp:regionpersondisplayname+=NameY -P -r -ext jpg -ext gif -ext jpeg -ext png "P:\"

For pictures that have RegionPersonDisplayName=NameX this works perfectly. However, silly me, it als creates the tag RegionPersonDisplayName=NameY in all other pictures :-(

How can I set up the command to only do replacement where NameX should be NameY?
Or, if needed, how can I make a list of pictures with RegionPersonDisplayName=NameX, so I can create the command for each individual picture and put this in a batch file?

Phil Harvey

There are a couple of ways to do this.  One is to process only files with NameX:

exiftool -if "$xmp:regionpersondisplayname =~ /NameX/" -xmp:regionpersondisplayname-=NameX -xmp:regionpersondisplayname+=NameY ...

But this will add NameY to any file where "NameX" is part of another name (eg. "NameX Surname" wouldn't be removed, but "NameY" would be added anyway).

Or you could change "NameX" to "NameY" anywhere it occurs:

exiftool "-xmp:regionpersondisplayname<${xmp:regionpersondisplayname;s/NameX/NameY/g or $_=undef}" -sep ## ...

The or $_=undef makes it so that the file won't be written if NameX isn't found.  The -sep ## option is required to separate the RegionPersonDisplayName string back into individual items.

- 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 ($).

mcwieger

I would never have been able to create that command. It does exactly want I want though  :D

Thanks a lot!