I was trying to think of a way to batch extract RAW files from DNG files and use the original filename. The only thing I came up with was a two step solution using a temp file.
First, run this
exiftool -ext DNG -p "#[IF] $OriginalRawFileName $OriginalRawImage" -p "#[BODY] -b" -p "#[BODY] -W" -p "#[BODY] %d$OriginalRawFileName" -p "#[BODY] -OriginalRawImage" -p "#[BODY] $Directory/$FileName" -p "#[BODY] -execute" /path/to/files/ >temp.txt
Then, you could run
exiftool -@ temp.txt
The first step creates a arg file (see -@ (Argfile) option (https://exiftool.org/exiftool_pod.html#ARGFILE)) which gives the commands to extract the embedded original RAW files with the original name into the same directory as the DNG
Some further thought, the output from the first could be piped into the second. Seemed to work with my quick test
exiftool -ext DNG -p "#[IF] $OriginalRawFileName $OriginalRawImage" -p "#[BODY] -b" -p "#[BODY] -W" -p "#[BODY] %d$OriginalRawFileName" -p "#[BODY] -OriginalRawImage" -p "#[BODY] $Directory/$FileName" -p "#[BODY] -execute" /path/to/files/ | exiftool -@ -
I was thinking about this myself. Your way is very smart, but tricky. It would have been better if I had a feature to embed tag names in the -W string, but doing this would take some work.
- Phil
Quote from: Phil Harvey on October 30, 2021, 05:27:48 PM
It would have been better if I had a feature to embed tag names in the -W string, but doing this would take some work.
That's what I figured. And I don't recall any time where it couldn't be worked around.
For most people, a simple
-W %d%f.nef or something similar would work. But it got me thinking about the edge case of if there wrere different embedded RAW file types.
Quote from: StarGeek on October 30, 2021, 05:45:22 PM
or most people, a simple -W %d%f.nef or something similar would work. But it got me thinking about the edge case of if there wrere different embedded RAW file types.
You can use
%s for the suggested extension of the file, and it should work for all raw files like this (it actually peeks at the extension of OriginalRawFileName to do this -- actually, maybe just adding a %o for the original raw file name would be enough since this is the most common use case).
- Phil
Quote from: Phil Harvey on October 30, 2021, 09:42:49 PM
You can use %s for the suggested extension of the file, and it should work for all raw files like this
I tried that before making this and the resulting file had a
.dat extension. At least for the embedded .orf file.
If the OriginalRawFileName tag existed then this shouldn't happen. If it did, we have a bug.
- Phil
Here's the command I used. The file saved is named PB290252.dat.
exiftool -W %d%f.%s -b -OriginalRawImage Y:\!temp\ccccc\d\a\PB290252.dng
As the image is not mine, I'm sending you a link..
Ah, great! Yes, bug. Thanks! This will be fixed in 12.35. I will also add a %o format code to represent OriginalRawFileName.
- Phil
Maybe also %O to match %f/%F?
Sure. Sounds good.
- Phil
Actually, I changed my mind. The uppercase format codes are for the -w option only, and are documented in that section. The extra -W format codes don't have uppercase equivalents, and I think I want to add %o to these. Also, if necessary, removing the extension can easily be done with %-.4o.
- Phil