Copy -CameraTemperature to XMP HierachicalKeyword?

Started by niels123, March 02, 2016, 10:13:07 AM

Previous topic - Next topic

niels123

The command:

exiftool -csv -r -CameraTemperature "input folder" > "output file"


outputs the CameraTemperature of each file in csv ("flat spreadsheet") format single text file. I'd like to have the sensortemp as a keyword in Lightroom, so I can filter and search on it to manually substract dark frames.

Does anybody know how I can give a single command with exiftool that writes for each CR2 file (including subfolders) the sensor temp to its corresponding XMP? The "read metadata from xmp" in lightroom should then import all the temp's in lightroom.

Thanx!
Niels

Phil Harvey

Hi Niels,

Something like this could do it:

exiftool -tagsfromfile %d%f.CR2 "-xmp:HierarchicalSubject+<cameratemperature" -ext xmp -r DIR

This command assumes that the XMP sidecar files already exist.  If they don't, you'll have to use the -srcfile option.  See example 13 on the Metadata Sidecar Files page for an example.

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

niels123

Thanks a lot for the fast reply!  ;D

Scripting and commandline interfaces are not my strongest point  ::) I did some testing and have taken a look at the examples in the link. It does work, but only when I place the specific name of a single CR2 file in the command line. It then only updates a single photo and I can't get it to update all CR2 sidecar files.

Phil Harvey

I don't understand.  What were the exact commands you used?  Both the one the worked and the one that didn't.

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

niels123

The command that does work:


c:\exiftool\exiftool -tagsfromfile 0F6A1498.CR2 "-xmp:HierarchicalSubject+<cameratemperature" -ext xmp -r q:\DF


And these do not work:


c:\exiftool\exiftool -tagsfromfile %d%f.CR2 "-xmp:HierarchicalSubject+<cameratemperature" -ext xmp -r q:\DF



c:\exiftool\exiftool -tagsfromfile *.CR2 "-xmp:HierarchicalSubject+<cameratemperature" -ext xmp -r q:\DF

Phil Harvey

Ah.  I was assuming that your CR2 and XMP files were in the same directory, and had the same names.  You'll have to change the command if this isn't true.

The command that works for you takes the temperature from 0F6A1498.CR2 in the current directory and applies it to all XMP files in q:\DF, but I don't think this is what you want to do.

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

niels123

Quote from: Phil Harvey on March 02, 2016, 11:35:03 AM
Ah.  I was assuming that your CR2 and XMP files were in the same directory, and had the same names.  You'll have to change the command if this isn't true.

The command that works for you takes the temperature from 0F6A1498.CR2 in the current directory and applies it to all XMP files in q:\DF, but I don't think this is what you want to do.

- Phil

My XMP's do have the same location and filename as my CR2 files. Indeed, I do not want to update each XMP file with the same temperature from a single CR2. What I want is to add the corresponding CR2 temperature to an existing XMP file with the same name and directory as the corresponding CR2.

Phil Harvey

OK then, you'll have to elaborate on why the command I gave didn't work.  It sounds like it should do what you want.  What messages did it give?  What version of ExifTool are you using?  What are the files in q:\DF?  Do the CR2 files in this directory have CameraTemperature 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 ($).

niels123

If I give the command:


c:\exiftool\exiftool -tagsfromfile %d%f.CR2 "-xmp:HierarchicalSubject+<cameratemperature" -ext xmp -r q:\DF


I get:

File 'f.CR2' does not exist for -tagsFromFile option


q:\DF is a small testdirectory with only 3 CR2 files from a 5D III which do contain the CameraTemperature info. I can see the temperature with exiftoolgui. I am using exiftool 9.6.7.0 (according to the properties dialog in windows)

Phil Harvey

Are you doing this in a .BAT file?  If so, then all "%" characters need to be doubled.

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

niels123

Yes, I created a .BAT file. I tried adding " or ' characters around %d%f.CR2, around %d%f and around the % only, but none work and I only get the same error message:


File 'f.CR2' does not exist for -tagsFromFile option

Phil Harvey

Hi Niels,

Right.  You should have mentioned the .bat file because it requires that the percent characters be doubled as I mentioned.  So the command is:

c:\exiftool\exiftool -tagsfromfile %%d%%f.CR2 "-xmp:HierarchicalSubject+<cameratemperature" -ext xmp -r q:\DF

Otherwise .bat interpreter will interpret "%d%" as a variable name.

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

niels123

Thanks a lot! It works  ;D My native language is Dutch, not English and for some reason I didn't get the meaning of double. I was thinking that to double in this context means adding the quotation marks.

I still have two questions, though:

How do I use the -srcfile option? I don't always already have an xmp file and I tried to just add it in the commandline, but I get an error:


Warning: Invalid VignettingCorrUnknown2 data
Error: File not found - -ext


How do I add the temperature as a subkeyword of, for example, "sensortemp"?

Phil Harvey

If the XMP's don't always exist, you do this (as from example 13 as I mentioned):

c:\exiftool\exiftool -tagsfromfile @ "-xmp:HierarchicalSubject+<cameratemperature" -ext CR2 -srcfile %%d%%f.xmp -r q:\DF

And I'm not sure what you mean by a subkeyword, but maybe it is something like this:

"-xmp:HierarchicalSubject+<sensortemp|${cameratemperature}"

which will add a string like this to the list of HierarchicalSubject values: "sensortemp|21 C"

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

niels123

Currently, I'm running the command on a large number of CR2 files, and (I think for some) I get:


Warning: Invalid VignettingCorrUknown2 data


Do you have any idea what it is and what I'm doing wrong? The files are from my 5D III and contain one or more space characters in de filename.