Dear all,
may I ask for your valuable advice again?
I am looking for a nice way to rename darktalbe-xmp with information necessarily coming from related nef/dng (and to improve my understanding for exiftool by the way)
The structure is as follows:
%d%f.%e #nef or dng
%d%f.%e.xmp # available for every image; darktable, first version
%d%f_01.%e.xmp # sometimes, if another version is created, eg bw version,
%d%f_02.%e.xmp # maybe more whatever versions in selected cases, eg 16:9 ratio etc.
...
I thought about a script with a loop:
#! /usr/bin/perl
$i=1;
while ($i != 0) {
$j +=1;
exiftool -ext nef -ext dng -tagsfromfile @ -d '%Y-%m-%d_%H%M%S' '-filename<${DateTimeOriginal}00_${model;s/\s//g}%+2c.%e.xmp' '-filename<${DateTimeOriginal}${subsectimeoriginal}_${model;s/\s//g}%+2c.%e.xmp' -srcfile %d%f_0$j.%e.xmp . ;
$i=$CountGoodWr;
}
This loop is not working for other reasons, which I have not sorted out jet. The exiftool command alone works fine aslong as you do not use $j in -srcfile, but instead eg 1 and change that number for every run in my tests...
(so, I can solve my renaming problem by hand, but that is not that nice ...)
My major questions are therefore as follows:
Is it possible to retrieve $CountGoodWr?
Is it possible to use a variable within the filename-definition, like -srcfile %d%f_0$j.%e.xmp ?
Or, in general, is there a smarter way to solve that problem?
Thank you so much,
Dirk
Hi Dirk,
I would do it a bit differently, and avoid the looping. I will present the command in argfile (-@) format since the argument list is fairly long:
-ext
xmp
-d
%Y-%m-%d_%H%M%S
-tagsfromfile
%d%f
-filename<${DateTimeOriginal}00_${model;s/\s//g}%+2c.%e.xmp
-filename<${DateTimeOriginal}${subsectimeoriginal}_${model;s/\s//g}%+2c.%e.xmp
-tagsfromfile
%d%-.7f%-4f
-filename<${DateTimeOriginal}00_${model;s/\s//g}%+2c.%e.xmp
-filename<${DateTimeOriginal}${subsectimeoriginal}_${model;s/\s//g}%+2c.%e.xmp
- Phil
Edit: Added a missing "%" character in the second -tagsFromFile argument
OK, one more thing to study :)
Thanks so much!
Dirk
Hi Phil, dear all,
without the looping, the code will safe a couple of hours when used with a significant number of image files!
In case, someone is interested in that code in the future, here is a little update with two changes:
First, -fileorder preserves the order in the updated image files, that:
oldname_01.DNG.xmp --> newname_01.DNG.xmp.
Second, the %e in -filename now needs to be changed to %-3f, that:
oldname.DNG.xmp --> newname.DNG.xmp
For matters of clarity, here is a simplified example code:
-ext
xmp
-fileorder
-d
%Y-%m-%d_%H%M%S
-tagsfromfile
%d%f
-testname<${DateTimeOriginal}00_${model;s/\s//g}%+2c.%-3f.xmp
-tagsfromfile
%d%-.7f%-4f
-testname<${DateTimeOriginal}00_${model;s/\s//g}%+2c.%-3f.xmp
Thanks again!
Best, Dirk
Great. Glad you found something that works for you.
- Phil