Compare commits

...

2 Commits

Author SHA1 Message Date
e1c92664be Vim: use 2-space indentation 2020-03-08 22:47:38 +00:00
d881964832 Add dt-import-geeqie-ratings 2020-03-08 21:55:44 +00:00
2 changed files with 40 additions and 2 deletions

4
.vimrc
View File

@ -43,8 +43,8 @@ set modelines=5 " Number of lines to check for vim: directives at the st
set autoindent " AutomaticAlly indent new line
" Indentation
set ts=4 " Number of spaces in a tab
set sw=4 " Number of spaces for indent
set ts=2 " Number of spaces in a tab
set sw=2 " Number of spaces for indent
set et " Expand tabs into spaces
" Mouse settings

38
bin/dt-import-geeqie-ratings Executable file
View File

@ -0,0 +1,38 @@
#!/bin/sh
set -e -u
SCRIPTNAME=`basename "${0}"`
usage() {
echo "Import (and overwrite!) Geeqie ratings to Darktable"
echo "Usage: ${SCRIPTNAME} DIRECTORY"
}
if [ "${#}" -ne 1 ] || [ ! -d "${1}" ] ; then
usage
exit 1
fi
# Don't touch XMP files while Darktable is running
[ "`pidof darktable`" ] && { echo "Error: Darktable is running, aborting." ; false ; }
DARKTABLE_DIR=`realpath "${1}"`
GEEQIE_DIR=`realpath "${HOME}/.local/share/geeqie/metadata${DARKTABLE_DIR}"`
RATING_FIELD="xmp:Rating"
count=0
for dt_xmp in `find "${DARKTABLE_DIR}" -maxdepth 1 -type f -name '*.xmp'` ; do
img=`echo "\`basename ${dt_xmp}\`" | sed 's/\.xmp$//'`
gq_xmp="${GEEQIE_DIR}/${img}.gq.xmp"
if [ -r "${dt_xmp}" ] && [ -r "${gq_xmp}" ] ; then
gq_rating=`grep "${RATING_FIELD}" "$gq_xmp" | cut -d'"' -f2`
dt_rating=`grep "${RATING_FIELD}" "$dt_xmp" | cut -d'"' -f2`
if [ "${gq_rating}" ] && [ "${dt_rating}" ] && [ ${gq_rating} -ne ${dt_rating} ] ; then
((++count)) # Pre-increment because post-increment fails with 'set -e' :)
echo "counted"
sed -i 's/'${RATING_FIELD}'="'${dt_rating}'"/'${RATING_FIELD}'="'${gq_rating}'"/' "${dt_xmp}"
fi
fi
done
echo "${count} ratings imported. Remember to activate sidecar scanning at Darktable start-up."