How to concatenate tag with text?

Started by Michael Tapes, August 06, 2011, 07:05:08 PM

Previous topic - Next topic

Michael Tapes

Hi Phil,

Simple issue which I cannot figure out.

Win 7...running Jeffrey Friedl's "Run any Command" from within Lightroom to call exiftools

As an example I would like to put "Mfg=Canon in Japan" in the Title field, taking the "Canon" from the metadata in the file using -make...

I can just set the Title to "Canon" using this:
"exiftool.exe" -overwrite_original -P  " "-Title<make"  "{FILE}"  [{FILE} gets the filename from lightroom]

But I cannot find how to use the -make data along with static text to form Mfg=Canon in Japan

Thanks..
Michael Tapes

Phil Harvey

Hi Michael,

This is outlined in the -tagsfromfile documentation, but it is very succinct and you must be looking for it.  The syntax is:

exiftool "-title<Mfg=$make" ...

With double quotes as above in Windows, or single quotes instead in Mac/Linux.

You can also put curly quotes around the tag name (ie. ${make}), which is necessary sometimes to separate it from subsequent text.

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

Michael Tapes

Thanks Phil,

I understand that now. I had tried with brackets, but Jeffrey's plug-in sees anything in brackets as a data token and issues an error as it tries to parse the unknown token. I will take the bracket conflict up with Jeffrey, but clearly the "$" works.

However, in this example, the serial number is extracted, but not the MicroAdjust value. Instead that returns the filename. I have tried it with and without the "makernote:" entry, but cannot get it to work. What am I missing? And how does one know if a group name (like iptc) below is required for a given tag. It appears to be required for caption, but not for serialnumber.

exiftool -overwrite_original -P  "-iptc:caption-abstract<Test2 = $MakerNotes:AFMicroAdjValue"  "-Title<Test2 = $SerialNumber"  "{FILE}"

Thanks.
Michael

BogdanH

Hi,
I just wish to say a welcome in ExifTool forum and that I miss the days we spend on RawShooter forum. I mean.. you are "that" M. Tapes? If not, welcome anyway  :)

Btw. I've tried command
exiftool -overwrite_original -P  "-iptc:caption-abstract<Test2 = $MakerNotes:AFMicroAdjValue"  "-Title<Test2 = $SerialNumber"
-from windows console and it works as expected. However Iptc won't be updated in case file doesn't contain AFMicroAdjValue tag (mfa isn't supported by camera, that is).

Group prefixes are necessary (preferred to be used) in case when the same tag name can appear in different groups. For example, tag City can be defined in Xmp or in Iptc. If you're sure that tag name is unique in metadata, then writting prefix is not necessary. Speaking for me: I use prefixes all the time (to avoid mistakes).

Bogdan

Michael Tapes

Hi Bogdan,

Thanks for the welcome, and I am that M. Tapes.

The camera file does have the data, but you have hit on something. As I said, I am running this from inside Lightroom, and in fact Adobe strips out that tag...I try to test things outside the LR environment, but I guess I missed it this time. I will have to speak with Jeffrey to see how I can get at the "negative" file to submit to ET rather than the exported file...or I could probably export it as a DNG and it will hold the tag.

Thanks...you have pointed me in a good direction.

M. Tapes (with history)
YarcPlus
Archive Creator
Capture One
RawShooter
Lightroom
WhiBal
LensAlign


Michael Tapes

#5
Hi Bogdan,

A real Daaaaaah moment for me. Lightroom has the ability to output the original file through the export process so that things like I am trying to do can be done (present the original to plug-ins). Of course it works fine now as one would expect.

Lightroom has really matured into an incredible application. Thanks again for getting me to look again!

Now I need to make the extraction generic so that the same call will work on Nikon, Canon and the rest, since the settings are called different tags in different cameras.

If you want to lend a hand to save me some time (this is very simple). What is the best way to adapt this so that it can extract either
makerNote:AFFineTuneAdj (Nikon) or  makerNote:AFMicroAdjustValue (Canon) into my field, like here:

"-Title<MicroAdjustValue = $MakerNotes:AFMicroAdjValue"

Thanks. If I get to it before I hear from you I will post..

Michael

BogdanH

Hi Michael,

I'm afraid I can't help on this (even it looks simple). I have tried few statements by using -if (which is the right direction, IMO) and it works... it's just, that I get many "warnings" messages from ExifTool (when working on mixed files), which doesn't "look nice".
Hopefully, Phil isn't that far away.. he has his own magic hat, you know  :)

Greetings,
Bogdan

Michael Tapes

Hi Bogdan,

No worries. Appreciate your help so far. I think I read of a manner of presenting the tags where you can present more than 1, and it takes the first one that is valid. Hopefully Phil can point me to his magic.

Thanks again.

MT

Phil Harvey

Welcome Michael,

Quote from: Michael Tapes on August 07, 2011, 10:56:21 AM
What is the best way to adapt this so that it can extract either
makerNote:AFFineTuneAdj (Nikon) or  makerNote:AFMicroAdjustValue (Canon) into my field,

Just try to copy both of them into the same tag.  The one that exists in the file wins! :)

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

CoSpi

Hi I have similar problem. I want to copy XMP regionpersondisplayname (which is array from Microsoft Photo Gallery) to XMP subject (array as well) as it is and to XMP hierarchicalSubject (again array) with prefix (MyTags|People|)

this is ok
exiftool -fast -overwrite_original "-subject<regionpersondisplayname" d:\01.jpg
but if I want to add the prefix I have to use $ and {} but this doesn't make array on output
this doesn't work
exiftool -fast -overwrite_original "-hierarchicalSubject<MyTags|People|${regionpersondisplayname}" d:\01.jpg

thank you for your help

Phil Harvey

So you want to add "MyTags|People|" to each person's name?  Try this:

exiftool "-hierarchicalSubject<${regionpersondisplayname;s/(^|==)/$1MyTags\|People\|/g}" -sep "==" DIR

Regular expressions like this can look confusing, but all this is doing is to add "MyTags|People|" at the start of the keywords and after each "==".  I am using "==" as a separator to avoid any conflict with commas in the people's names.

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

CoSpi

Thank you for your quick reply
I tried it and it adds MyTags|People| just to the first record in regionpersondisplayname array.
What I am trying to do is tag all the people on my pictures in Microsoft Photo Gallery and than be able to filter pictures by names in XnViewMP.

Phil Harvey

It should add the prefix to all the names.  Here is what I get (the quoting is different because I am on a Mac):

> exiftool a.jpg -regionpersondisplayname
Region Person Display Name      : me, you
> exiftool a.jpg '-hierarchicalSubject<${regionpersondisplayname;s/(^|==)/$1MyTags\|People\|/g}' -sep '=='
    1 image files updated
> exiftool a.jpg -hierarchicalSubject
Hierarchical Subject            : MyTags|People|me, MyTags|People|you


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

CoSpi

hmm ok, so we have to find the difference.
I am using exiftool.exe version 9.9.9.0 and I am getting this results


Microsoft Windows [Version 10.0.10240]
(c) 2015 Microsoft Corporation. Všechna práva vyhrazena.

D:\Programs\ExifTool>exiftool a.jpg -regionpersondisplayname
Region Person Display Name      : Krist├Żna Jirkova, Martin Hol├Ż

D:\Programs\ExifTool>exiftool a.jpg "-hierarchicalSubject<${regionpersondisplayname;s/(^|==)/$1MyTags\|People\|/g}" -sep "=="
    1 image files updated

D:\Programs\ExifTool>exiftool a.jpg -hierarchicalSubject
Hierarchical Subject            : MyTags|People|Krist├Żna Jirkova, Martin Hol├Ż

Phil Harvey

Very odd.  It isn't doing the proper substitution for the separator.  Are you sure the RegionPersonDisplay name is a proper array?  What is the output of this command?:

exiftool a.jpg -regionpersondisplayname -sep "=="

If the names show up as comma-separated, then they are a simple string.  In which case, you should use a command like this:

exiftool a.jpg "-hierarchicalSubject<${regionpersondisplayname;s/(^|, )/$1MyTags\|People\|/g}" -sep ", "

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