Hi everyone. I have struggled a lot with the decision, with the painful move from Aperture to Lightroom still fresh in my mind. But after Adobe stopped working on the standalone version of LR and before it’s too late I’ve made the big jump, from mac+lightroom to linux+darktable. I trust in open source and hope that DT can continue to exist for many years to come.
I am currently working to avoid losing all the metadata I have filled in over the years, with the idea to recreate all collections that I had in Lightroom (vacations/country_A, country_B, etc). My LR database consists of over 70k photos.
Stars and tags are ok, but I’ve noticed that the Location and Country keywords are not copied when importing raws and their xmp sidecars over from Lightroom.
I have come up with a bash script that uses exiftool
to copy the content of those two keywords into hyerarchical tags:
#! /bin/sh
raws=(".NEF" ".RAW" ".ORF")
OIFS="$IFS"
IFS=$'\n'
for RAW in "${raws[@]}"; do
for FILE in `find . -type f -iname "*${RAW}"`; do
INPUT=$(basename ${FILE} ${RAW}).xmp
OUTPUT=$FILE.xmp
LOCAT=$(exiftool -t -S -xmp:location "${INPUT}" | cut -d":" -f 1)
COUNT=$(exiftool -t -S -xmp:country "${INPUT}" | cut -d":" -f 1)
if [[ $LOCAT ]]; then
exiftool "-xmp:Subject+=$COUNT" "-xmp:Subject+=$LOCAT" "-xmp:HierarchicalSubject+=$COUNT|$LOCAT" $OUTPUT
fi
done
done
IFS="$OIFS"
What this script does is to extract Location and country from the original Lightroom sidecar and, if they do exist, write them as normal tags to the xmp.Subject
field (for example: Italy,Rome
) and as hyerarchical tags with first level set to “Location” to the xmp:HierarchicalSubject
field (for example: Location|Italy|Rome
).
The files I’m importing are Nikon, Olympus and Fuji’s raws (respectively NEF
, ORF
and RAF
extensions).
When the raws get imported in Darktable these tags should also be read and copied as normal tags that I can then use to make collections, albums or whatever they’re called (still need to figure out this part).
I have random questions and things to do:
- is exiv2 a better choice for this task? Will need to figure out the syntax in that case. I have the impression that darktable uses exiv2 because is faster perhaps? Also I seem to be unable to read Darktable tags (once the file is imported) while I can see them using exiv2 (
Xmp.dc.*
; I think that the keywords where DT stores them areXmp.dc.Subject
andXmp.lr.hierarchicalSubject
). - need to add a loop for jpeg files too
If anybody is facing similar problems and wants to collaborate or help me with the above please let me know.
thanks!
UPDATE I have modified the script above and it has worked on a test folder, I am now trying it on another folder with >4000 files and will let you know the results tomorrow.
The main changes have been on the find
line at the beginning of the loop to also take into account names with spaces (together with the IFS
and OIFS
lines), I have also removed the overwrite_original option in exiftool so that if anything goes wrong you only need this command to restore the originals. Finally, I changed the way to add tags to xmp.Subject
and xmp:HierarchicalSubject
so that existing tags are not overwritten (but I simply append country and location).
exiftool -restore_original -ext xmp
while to delete the originals once everything works as intended:
exiftool -delete_original -ext xmp