Author Topic: xmp, darktable, loop  (Read 250 times)

dtw

  • Newbie
  • *
  • Posts: 9
xmp, darktable, loop
« on: February 13, 2019, 01:51:32 AM »
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:
Code: [Select]
#! /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

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14879
    • ExifTool Home Page
Re: xmp, darktable, loop
« Reply #1 on: February 13, 2019, 07:36:59 AM »
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:

Code: [Select]
-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
« Last Edit: February 14, 2019, 09:27:23 AM by Phil Harvey »
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

dtw

  • Newbie
  • *
  • Posts: 9
Re: xmp, darktable, loop
« Reply #2 on: February 13, 2019, 05:26:26 PM »
OK, one more thing to study  :)
Thanks so much!
Dirk

dtw

  • Newbie
  • *
  • Posts: 9
Re: xmp, darktable, loop
« Reply #3 on: February 16, 2019, 10:22:49 AM »
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:

Code: [Select]
-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

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14879
    • ExifTool Home Page
Re: xmp, darktable, loop
« Reply #4 on: February 16, 2019, 01:17:31 PM »
Great.  Glad you found something that works for you.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).