Add Bash Shell Scripts to the Import Module in digiKam

The default functionality of the Import module in digiKam can be extended by linking a Bash shell script to the import operation. This way, you can perform a wide range of actions on the imported files: from manipulating them using command-line tools like ImageMagick, to backing up the imported photos. The latter in particular can make the overall photographic workflow more efficient by combining the import and backup steps into a single operation. This also means that you can back up photos and RAW files directly from within digiKam, without resorting to a dedicated backup tool.

To add backup powers to the Import module, you need to write a simple Bash shell script first. The example code below creates a target directory using the mkdir command and then backs up each transferred photo to it using the rsync tool:

mkdir -p $2
rsync -a $1 $2

The $1 and $2 variables are replaced by the full path and file name and destination path that are passed to the script from the Import module. Paste the code into a new text file and save it under the name. Make the resulting script executable using the chmod +x command.


In digiKam, open the Import module and switch to the Settings sidebar. Scroll down to the Scripting section, and specify the path to the script in the Execute script for image field as follows:

/path/to/ %file '/path/to/target/dir'

The %file placeholder passes the name of the currently transferred file to the script, while /path/to/target/dir provides the script with the path to the target directory.

The Import module supports several other placeholders that can be used in scripts. This includes %filename (the file name of the imported file), %path (path of the imported file), %orgfilename (original file name), and %orgpath (original path).

This is an excerpt from the digiKam Recipes book. Get your copy from Google Play Store or Gumroad.

Tech writer covering Linux and open source software

Tagged with: , ,
Posted in Photography, Scribbles
One comment on “Add Bash Shell Scripts to the Import Module in digiKam
  1. tuxflo says:

    I really like this feature a lot, I use it for automatically importing existing XMP sidecar files to my digikam library.

Comments are closed.

Recipes for automated and streamlined photographic workflow on Linux

Use digiKam? Get this book!

Practical advice for nighttime photography

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

%d bloggers like this: