Update EXIF info in raw, and .xmp sidecar if it exists

Started by busywait, November 12, 2016, 12:21:07 PM

Previous topic - Next topic

busywait

Hello,

I've been learning how to use exiftool to add Lens exif tags to my camera raw and jpeg files. I've got the basics working, but I'd like to get fancy.

I want to call exiftool from inside ACDsee image manager as an "external editor". In this case ACDsee will run an exiftool command line with a list of one or more raw file names. I would like exiftool to update the raw files, and *if they exist* also update the corresponding .xmp sidecar files. This FAQ example is almost what I need (from http://www.exiftool.org/metafiles.html
):
exiftool -ext EXT -artist="Phil" -srcfile %d%f.xmp -srcfile @ DIR
That will not update the raw file if the .xmp exists - I'd like them both done in that case.

Currently I'm using this command line in a Windows "Send to" shortcut
c:\utils\exiftool\exiftool.exe -@ c:\utils\exiftool-options\interactiveOptions.txt -@ c:\utils\exiftool-options\myLens.txt

interactiveOptions.txt contains

-k
-progress
-progress:


myLens.txt contains something like

-LensMake=Tamron
-LensModel=Tamron SP 500mm f/8 Mirror 55BB
-LensInfo=500 mm f/8
-FNumber=8
-MaxApertureValue=8
-FocalLength=500 mm


Does anyone have any clues for me?

Phil Harvey

Are you copying information, or just writing new values?  If the latter, then just add a -ext option for both the raw file and the XMP to update both.

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

busywait

Thank you Phil! I think -ext could work if I was calling exiftool with a directory, but my command gets called by ACDsee image manager, or perhaps by Windows "Send to", with a single extra argument that is a raw file.

When I'm using Windows File Explorer it's easy for me to select the raw/.orf file and the .xmp together so everything works as I need. ACDsee only shows the image file, not the .xmp, and so only passes the .orf files to my exiftool command line:
c:\utils\exiftool\exiftool.exe -@ c:\utils\exiftool-options\interactiveOptions.txt -@ c:\utils\exiftool-options\myLens.txt rawFile.orf

In this case I am just writing or over-writing new tags, not copying between files.

busywait

Here is a command that does almost what I want:
exiftool.exe -execute -execute -o %d%f.xmp -common_args  -@ myLens.txt rawFile.orf

The problem is that it will always create an xmp. That's kind of OK if I'm tagging a raw file because anything else I do to it will cause a .xmp to be generated anyway. Sometimes I'll tag a JPEG using this command, and then creating the .xmp is really not wanted.

Thank you for creating and supporting exiftool!

Phil Harvey

#4
You have one extra -execute in that command that you don't need.

Also, your command won't write to the XMP file if it already exists.  I think you want to do this:

exiftool.exe -execute -srcfile %d%f.xmp -common_args -@ myLens.txt rawFile.orf

But yes, it will always create the XMP file.  There are probably ways around this if you really want, but I would have to think about it some more.

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

busywait


Phil Harvey

Yes, this is something I had been thinking about.  You can do it like this:

exiftool.exe -execute -srcfile %d%f.xmp -if "-e $filepath" -common_args -@ myLens.txt rawFile.orf

Also, to avoid running the command on JPG files (in case you don't know what type the FILE is), you could do this:

exiftool.exe -execute -srcfile %d%f.xmp -if "-e $filepath" -common_args -@ myLens.txt --ext jpg FILE

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

busywait

Thanks, I think I need the --ext in front of the -common_args option don't I? Then it seems to do just what I asked for, thanks!

I decided to use some -ext include options for the raw formats I have instead of --ext to exclude jpeg, as below, does that seem to make sense?

exiftool.exe -execute -srcfile %d%f.xmp -if "-e $filepath"  -ext orf -ext mrw -ext rw2 -common_args -@ myLens.txt FILE


Phil Harvey

Quote from: busywait on November 14, 2016, 11:17:27 AM
Thanks, I think I need the --ext in front of the -common_args option don't I?

This depends.  If you want to write tags to the JPG (the first command), then yes.  But if you want to disable the command completely for JPG's, then put it after the -common_args to apply to both the JPG and XMP commands.

Using inclusions with -ext instead of excluding the JPG only makes sense.

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