Failure creating xmp file with -TagsFromFile

Started by Allan Olesen, March 04, 2012, 05:09:19 PM

Previous topic - Next topic

Allan Olesen

I have some .ARW files with some wrong lens information in them. I want to correct that by writing an .xmp file with the correct info prior to importing the .ARW files into Lightroom.

I have come up with this which runs in a Windows 7 batch script (.bat):
exiftool -o %%d%%f.xmp --all:all -lens="Minolta MD 135mm F2.8" -focallength="135/1" -fnumber=99 -maxaperturevalue=2.8 -lensinfo="135/1 135/1 28/10 28/10" -lensmodel="135mm F2.8"  %2

%2 is the name and path of the .ARW file.

The above command works, but it will not change info in an existing .xmp file.

To allow changing info in an existing .xmp file, it seems I have to use a completely different syntax like this:
exiftool -TagsFromFile %2 --all:all -lens="Minolta MD 135mm F2.8" -focallength="135/1" -fnumber=98 -maxaperturevalue=2.8 -lensinfo="135/1 135/1 28/10 28/10" -lensmodel="135mm F2.8" %%d%%f.xmp
However, when I use that, the xmp file is named "%d%f.xmp".

If I change %%d%%f.xmp in the command into %d%f.xmp, the xmp file is named "f.xmp".


Phil Harvey

You're right.  You must use a different syntax if you want to edit an existing metadata file.  Try this:

exiftool -tagsfromfile @ --all:all -lens="Minolta MD 135mm F2.8" -focallength="135/1" -fnumber=99 -maxaperturevalue=2.8 -lensinfo="135/1 135/1 28/10 28/10" -lensmodel="135mm F2.8" -srcfile %%d%%f.xmp %2

See the "Batch Processing" section of the XMP metadata sidecar files documentation for more information.

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

Allan Olesen

#2
Thanks, it worked.

Is my syntax for the tags correct? I don't know if I am supposed to enter the decimal values as fractions in the same way as in the exiftool output, or if I should just write them as ordinary decimal values. Which of the below examples are correct?
-lensinfo="135/1 135/1 28/10 28/10"
-lensinfo="135 135 2.8 2.8"

And another question:
I set the F Number tag to 99 because it is unknown. (The lens in question is an old manual lens which is chipped but always report the same aperture). Is there a more correct way to state that aperture is unknown? I can't just leave out the tag since Lightroom will just extract it from the raw file if it is not in the xmp file.

And a third question:
It seems that Lightroom uses my lens name when importing the photos, but it ignores the focal length and f number info, even when I use a normal f number value like 32. Any insight on this?



Phil Harvey

The best way to figure out the correct syntax is to try it out.

In this case, ExifTool is very flexible, and both of the ways you mention work fine.  ExifTool will reformat it to the proper EXIF format.

However, in general the input should be in the same format as the output, which for LensInfo is like this: "50-135mm f/3.5-4.0".

Q2: I'm not sure what the EXIF specification states, but you could try setting FNumber to 'undef' since the EXIF rational format supports the notion of an undefined value.

Q3: I am surprised if LR ignores the EXIF FNumber and FocalLength.  But I'm not an LR expert.

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

Allan Olesen

Ok. Thanks for the help.

Just for the record:
I did try both syntaxes for several of the tags prior to asking. For some tags exiftool would allow both, and for other tags it would only allow the decimal numbers. But using the decimal numbers had some strange consequences like MaxApertureValue 2.8 being converted into 24361/8200 which is actually 2.97.

Phil Harvey

MaxApertureValue is stored as an APEX value and converted to an F number by ExifTool, so there are other factors at play here.  There is sometimes a round-off which occurs when converting to/from APEX values.

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