[digiKam-users] Execute a custom script on folder

Peter Albrecht peter at crazymonkeys.de
Sun May 13 12:22:18 BST 2018


Hi!

a "dirty hack":
I use "Open With" from the context menu (rightclick) of a photo to manipulate
this photo with a custom bash script. In this script, you could use "dirname"
(see https://stackoverflow.com/a/6121114/1098572) to extract the directory of
the pictures path. Then you could process this directory.

=> you don't rightclick a album, but any picture in this album to process the
whole album.


How To add your script to the "Open With" dialog of KDE:

1. create a desktop-file, like: "myRawCleaner.desktop" and put it in:
     ~/.local/share/applications
  or /usr/local/share/applications

2. content of "myRawCleaner.desktop":
----------------------------- 8< -----------------------------
[Desktop Entry]
Name=myRawCleanScript
GenericName=general description
Comment=Some comment
Icon=resizeimages
Exec=/usr/bin/konsole --noclose -e /bin/bash /usr/local/bin/rawCleanScript.sh %F
Type=Application
MimeType=image/jpeg
Terminal=false
----------------------------- >8 -----------------------------
I guess, you have to change "MimeType=image/jpeg" to something matching your RAW
files.

3. Now digiKam should show "myRawCleanScript" in the context menu of your RAW
files in the "Open With"-submenu.

Hope this helps.

Regards,
	Peter


On 13.05.2018 10:38, hleroy wrote:
> 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