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 |
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 > |
Nice hack Peter. It worked perfectly.
For those interested, the files: ~/.local/share/applications/myRawCleaner.desktop [Desktop Entry] Name=Keep CR2 for rated photos Exec=/usr/bin/konsole -e /bin/bash ~/Scripts/keepRawForRatedPhotos.sh %F Type=Application MimeType=image/x-canon-cr2 Terminal=false ~/Scripts/keepRawForRatedPhotos.sh #!/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) # # It requires a filename as argument. It is meant to be called through a "context menu" # (right-click) on a picture # # Example .desktop file for KDE (to be placed in ~/.local/share/applications/myRawCleaner.desktop) # [Desktop Entry] # Name=Keep CR2 for rathed photos # Exec=/usr/bin/konsole -e /bin/bash ~/Scripts/keepRawForRatedPhotos.sh %F # <-- adjust the script location here # Type=Application # MimeType=image/x-canon-cr2 # Terminal=false # # **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 that first argument is a file, then extract folder name if [ -e "$1" ]; then ALBUM=$(dirname "$1") else # Otherwise exit exit 1 fi # 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 the folder cd "$ALBUM" RATED_JPG=`exiftool -m -if '$Rating' *.JPG -q -p '$FileName'` if [[ -z "$RATED_JPG" ]]; then echo "No rated photos" else # 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 fi # Trash remaining Raw files in current folder (needs trash-cli package) trash-put *.CR2 # Wait for a key press before exiting read -n 1 -s -r -p "Press any key to continue" -- Sent from: http://digikam.1695700.n4.nabble.com/digikam-users-f1735189.html |
The gist on Github for a properly formatted file:
https://gist.github.com/hleroy/ef7dd5c7fbc769d73c12fdf56bc4881e -- Sent from: http://digikam.1695700.n4.nabble.com/digikam-users-f1735189.html |
Right click hack wouldn't work in Windows would it? Sent from a fair mobile On Sun, 13 May 2018, 23:05 hleroy, <[hidden email]> wrote: The gist on Github for a properly formatted file: |
Free forum by Nabble | Edit this page |