[digiKam-users] Execute a custom script on folder

hleroy hleroy at hleroy.com
Sun May 13 09:38:30 BST 2018


In my workflow, I keep RAW files only for the photos I have rated. I have
written a small script which I run from the terminal. It checks with
Exiftool if the JPG photo is rated. If yes, it moves the corresponding RAW
file to a subfolder. Then it deletes the remaining RAW files.

Is there a way to execute a custom script (bash, python,...) *on an album*
from the Digikam interface ? i.e. calling the script and passing the album
path as an argument to the script.

Thanks

Below the script in case someone has a similar need.

#!/bin/bash
#
# This script will delete all Raw (CR2) files when the corresponding JPG is
unrated.
#
# The purpose is to keep only Raw files for photos which are worth it
# (assuming you have gone through the effort of rating them)
#
# **WARNING**
# Make sure to be in the right folder before running this script,
# because it will trash all Raw files with no matching rated JPG
#
# Requires:
#   exiftool
#   trash-cli

# Check requirements
hash exiftool 2>/dev/null || { echo >&2 "I require exiftool but it's not
installed.  Aborting."; exit 1; }
hash trash-put 2>/dev/null || { echo >&2 "I require trash-put but it's not
installed.  Aborting."; exit 1; }

# List all rated JPG file in current folder
RATED_JPG=`exiftool -m -if '$Rating' *.JPG  -q -p '$FileName'`

# Create 'Raw' sub-folder if it doesn't exist
if [ ! -d Raw ]; then
  mkdir Raw
fi

# Set line break as field separator and loop throuh all rated JPG files
IFS=$'\n'
for JPG in $RATED_JPG
do
  CR2=${JPG::-4}'.CR2'

  if [ -f "$CR2" ]; then
    echo 'Moving '$CR2
    mv $CR2 Raw
  fi
done

# Trash remaining Raw files in current folder (needs trash-cli package)
#trash-put *.CR2




--
Sent from: http://digikam.1695700.n4.nabble.com/digikam-users-f1735189.html



More information about the Digikam-users mailing list