Use tag value as filename when extracting data

Started by v16p20, November 18, 2020, 03:23:57 PM

Previous topic - Next topic

v16p20

Hi,

is it possible to use the value of a tag as filename when extracting data?

In my case I want to extract the RAW embedded in DNG [-OriginalRawImage] and name it with the original filename [-OriginalRawFileName]

exiftool -b -OriginalRawImage -w temp file.dng

So I woud like to change "temp" to something like "-filename<OriginalRawFileName".


Thanks



Phil Harvey

This could be done in two steps:

1. exiftool -p "exiftool -b -originalrawimage $directory/$filename -W $directory/$originalrawfilename" -ext dng DIR > out.bat

2. out.bat

(assuming you're running from Windows cmd.exe)

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

v16p20

Thank you Phil. Your solution works perfect. Exiftool never disappoints.

Here's an addition: to extract the RAW with the current name of the DNG and the extension of OriginalRawFileName I used

exiftool -p "exiftool -b -originalrawimage $directory/$filename -W $directory/${filename;s/(.+?)(\.[^.]*$|$)/$1/}.${originalrawfilename;s/.*\.([^.]*)/$1/}" -ext dng DIR > out.bat

Or is there any other solution?

Phil Harvey

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