Copy tagvalue to Darktable sidecar

Started by canis42, July 24, 2024, 05:30:46 PM

Previous topic - Next topic

canis42

I am using Linux Mint 21.3 with Cinnamon gui.
I have 20,000 .dng image files in a deep folder structure and administrate them with darktable. darktable writes XML files with metadata beside each image file (they call them "sidecars".

In the imagefiles I have Texts in the Headline fields written using Lightroom. I would need to copy them to the title field in the existing XMP files so darktable handles them.

I tried many possible command line formats with exiftool but did not succeed. How must look the command line?

It was easy to copy the heafline to the title in the dng-imagefiles with exiftool.

Phil Harvey

The syntax is

exiftool "-DESTINATION_TAG<SOURCE_TAG" FILE

See FAQ's 2 and 3 for help figuring out the tags to use.

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

canis42

Found that out and copied the tag from Headline to Title - no problem.

But how do I add the title to the xmp file?

Phil Harvey

Sorry.  This writes to the XMP sidecar:

exiftool "-DESTINATION_TAG<SOURCE_TAG" -srcfile %d%f.xmp FILE

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

canis42

Quote from: Phil Harvey on July 25, 2024, 09:19:35 AMSorry.  This writes to the XMP sidecar:

exiftool "-DESTINATION_TAG<SOURCE_TAG" -srcfile %d%f.xmp FILE

- Phil


yes, ok, thank you, that works very well for one file. Can you also tell me how to do that for 20.000 files in dozens of directories and subdirectories? That would be really great.

Sorry I had a lot of different problems too solve, that is why I answer so late.

canis42

THank you very much for trying to help! Sorry, I told too fast it did work.

Let me show in detail:

Now this is the start situation:
mario@Hugin2:/media/mario/Data/photo/originals/Ägypten (Kopie)/test$ exiftool -Headline  *
======== ae0004.dng
Headline                        : Grabbezirk des Djoser
======== ae0004.dng.xmp
======== ae0005.dng
Headline                        : Umfassungsmauer
======== ae0005.dng.xmp
    4 image files read
mario@Hugin2:/media/mario/Data/photo/originals/Ägypten (Kopie)/test$ exiftool -Title  *
======== ae0004.dng
======== ae0004.dng.xmp
======== ae0005.dng
======== ae0005.dng.xmp
    4 image files read

Note that the xmp file does not contain the headline nor the title.

Lets copy headline to title:
mario@Hugin2:/media/mario/Data/photo/originals/Ägypten (Kopie)/test$ exiftool "-Title<Headline"  *
Warning: No writable tags set from ae0004.dng.xmp
Warning: No writable tags set from ae0005.dng.xmp
    2 image files updated
    2 image files unchanged
mario@Hugin2:/media/mario/Data/photo/originals/Ägypten (Kopie)/test$ exiftool -Title *
======== ae0004.dng
Title                           : Grabbezirk des Djoser
======== ae0004.dng_original
======== ae0004.dng.xmp
======== ae0005.dng
Title                           : Umfassungsmauer
======== ae0005.dng_original
======== ae0005.dng.xmp
    6 image files read

now I try to use your code only for picture 4

All I get is an extra xmp file, that I don't need that does not contain the title:

mario@Hugin2:/media/mario/Data/photo/originals/Ägypten (Kopie)/test$ ls
ae0004.dng           ae0004.dng.xmp  ae0005.dng_original
ae0004.dng_original  ae0005.dng      ae0005.dng.xmp
mario@Hugin2:/media/mario/Data/photo/originals/Ägypten (Kopie)/test$ exiftool "-Title<Headline" -srcfile %d%f.xmp ae0004.dng
    1 image files created
mario@Hugin2:/media/mario/Data/photo/originals/Ägypten (Kopie)/test$ ls
ae0004.dng           ae0004.dng.xmp  ae0005.dng           ae0005.dng.xmp
ae0004.dng_original  ae0004.xmp      ae0005.dng_original
mario@Hugin2:/media/mario/Data/photo/originals/Ägypten (Kopie)/test$ exiftool -Headline *
======== ae0004.dng
Headline                        : Grabbezirk des Djoser
======== ae0004.dng_original
Headline                        : Grabbezirk des Djoser
======== ae0004.dng.xmp
======== ae0004.xmp
======== ae0005.dng
Headline                        : Umfassungsmauer
======== ae0005.dng_original
Headline                        : Umfassungsmauer
======== ae0005.dng.xmp
    7 image files read

What I want to get is:

======== ae0004.dng.xmp
Headline                        : Grabbezirk des Djoser

Does not seem to be soooo easy ;)

canis42

SORRY, correction.

What I want to get is:
======== ae0004.dng.xmp
Title                      : Grabbezirk des Djoser

If really nobody has a solution with exiftool, then I have to extract the titles with exiftool and then change the darktable SQL database with a python program.

Phil Harvey

Your command will do exactly what you want.  But you should add -ext dng so you use only the DNG files as source 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 ($).

StarGeek

One change to make would be to use
-srcfile %d%F.xmp
instead of
-srcfile %d%f.xmp

In most cases, the XMP sidecar files are the "<Basename>.XMP". But in your case, the sidecar files are "<Basename>.<BaseExtension>.XMP"

The difference between %f and %F is that the latter includes the extension of the original filename.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).