Part of tags to xmp -> how?

Started by niels123, January 03, 2019, 04:29:57 PM

Previous topic - Next topic

niels123

To filter on photos in Lightroom I export certain tags into xmp files as keywords so I can easily find them in lightroom. Recently I purchased the Sony A7r III, which has the pixel shift multishot function. I'd like to filter on this feature in Lightroom, including selecting only file 1/4 (or any other file) in the sequence. The PixelShiftInfo tag contains this information and it could look like this:

Group 10170146, Shot 1/4 (0x154)

I think the Group [number] part is to identify which set of 4 shots form one group. To filter more easily, I'd like to extract only the 'Shot 1/4' part of this tag so I can select 1/4, 2/4 etc. When Pixel Shift Multishot is disabled, the tag gets n/a (I assume it is stored as 0).

How can I extract only the 1/4, 2/4, 3/4 or 4/4 part of this tag into an xmp keyword?

Niels

Stephen Marsh

I'd start by using the following command to find the full tag group and name:

exiftool -a -G1 -s FILE


https://exiftool.org/index.html#tagnames

https://exiftool.org/faq.html#Q2

niels123

Quote from: Stephen Marsh on January 03, 2019, 05:25:54 PM
I'd start by using the following command to find the full tag group and name:

exiftool -a -G1 -s FILE


https://exiftool.org/index.html#tagnames

https://exiftool.org/faq.html#Q2


See attached a text file with the output

Stephen Marsh

I don't have a sample file to test with so I tested using Canon:LensType from one of my files, however I would try either of the following to start and then report back:

exiftool -sep " " -tagsfromfile @ '-subject+<${Sony:PixelShiftInfo}' -r 'FILE or DIR'

exiftool -tagsfromfile @ '-subject+<${Sony:PixelShiftInfo}' -r 'FILE or DIR'

Good luck!

(change the single straight quotes for double straight quotes on Windows OS)

Phil Harvey

Hi Niels,

To write only the fraction part to XMP:Subject, try this:

exiftool "-subject+<${Sony:PixelShiftInfo;$_ = m[(\d+/\d+)] ? $1 : undef}" -r DIR

(the -tagsfromfile @ is not necessary when copying one tag to another with "<")

- 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: Stephen Marsh on January 04, 2019, 06:19:04 AM
I don't have a sample file to test with so I tested using Canon:LensType from one of my files, however I would try either of the following to start and then report back:

exiftool -sep " " -tagsfromfile @ '-subject+<${Sony:PixelShiftInfo}' -r 'FILE or DIR'

exiftool -tagsfromfile @ '-subject+<${Sony:PixelShiftInfo}' -r 'FILE or DIR'

Good luck!

(change the single straight quotes for double straight quotes on Windows OS)

What I have used and yields the complete tag is:
exiftool -tagsfromfile @ "-xmp:HierarchicalSubject+<PixelShiftInfo|${PixelShiftInfo}" -ext ARW -srcfile %%d%%f.xmp -r 'PATH'

I tried both commands you suggested, but get a 'file not found' error. I uploaded a sample raw on dropbox. Would you mind to see if you can get it working?
https://www.dropbox.com/s/wrqvdv01n53wma2/A7R06125.ARW?dl=1

Thanks!
Niels

Stephen Marsh

I'm sure that Phil's method will work, as is or with adjustment depending on your needs!

My method worked to copy the full tag using your sample file... However Phil has mentioned that the -TagsFromFile was superfluous with my syntax.

niels123

Quote from: Phil Harvey on January 04, 2019, 07:06:19 AM
Hi Niels,

To write only the fraction part to XMP:Subject, try this:

exiftool "-subject+<${Sony:PixelShiftInfo;$_ = m[(\d+/\d+)] ? $1 : undef}" -r DIR

(the -tagsfromfile @ is not necessary when copying one tag to another with "<")

- Phil


Thanks for the reply! My exiftool skills are not nearly as good enough as I'd like them to be. I tried on a test dir and get an ARW_original file, not an xmp file. How can I have the part written to an xmp file (or an existing xmp file if one already exists)?

Phil Harvey

That is where the -tagsfromfile option may be needed.  But what do you want to do if the XMP file doesn't exist?  This command will only write to existing XMP files:

exiftool -tagsfromfile %d%f.NEF "-subject+<${Sony:PixelShiftInfo;$_ = m[(\d+/\d+)] ? $1 : undef}" -ext xmp -r DIR

Or a bit more advanced... This command will also create XMP files if they don't already exist:

exiftool "-subject+<${Sony:PixelShiftInfo;$_ = m[(\d+/\d+)] ? $1 : undef}" -ext nef -srcfile %d%f.xmp -r DIR

See this page for more information than you ever wanted to know about dealing with metadata sidecar files.

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