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:
#!/bin/bash mkdir -p $2 rsync -a $1 $2
$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 import-backup.sh name. Make the resulting script executable using the
chmod +x import-backup.sh 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/import-backup.sh %file '/path/to/target/dir'
%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).