nr a révisé ce gist 2 weeks ago. Aller à la révision
1 file changed, 42 insertions
nef-to-jpg.sh(fichier créé)
| @@ -0,0 +1,42 @@ | |||
| 1 | + | #!/bin/bash | |
| 2 | + | ||
| 3 | + | # Converts all files in current directory | |
| 4 | + | # ending with *.NEF to JPEGs (.jpg) using darktable-cli | |
| 5 | + | # Based on: | |
| 6 | + | # https://askubuntu.com/a/1337782 | |
| 7 | + | ||
| 8 | + | set -eo pipefail | |
| 9 | + | ||
| 10 | + | err() { | |
| 11 | + | ( 1>&2 echo -e "[Error]\n$1\nExiting" ) | |
| 12 | + | exit 1 | |
| 13 | + | } | |
| 14 | + | ||
| 15 | + | main() { | |
| 16 | + | command -v "darktable-cli" &>/dev/null || err "Expected command darktable-cli to be available" | |
| 17 | + | ||
| 18 | + | local nefs=() | |
| 19 | + | mapfile -t nefs < <(find_nefs) | |
| 20 | + | ||
| 21 | + | local i= | |
| 22 | + | local nef= | |
| 23 | + | local jpgname= | |
| 24 | + | for (( i = 0; i < ${#nefs[@]}; i++ )); do | |
| 25 | + | nef="${nefs[i]}" | |
| 26 | + | jpgname="$( basename -s ".NEF" "$nef" ).jpg" | |
| 27 | + | ||
| 28 | + | echo "$i: ${nef} -> ${jpgname}" | |
| 29 | + | ||
| 30 | + | [ -f "$jpgname" ] && err "JPEG file named \"${jpgname}\" already exists" | |
| 31 | + | ||
| 32 | + | darktable-cli "$nef" "$jpgname" | |
| 33 | + | done | |
| 34 | + | ||
| 35 | + | echo "Done" | |
| 36 | + | } | |
| 37 | + | ||
| 38 | + | find_nefs() { | |
| 39 | + | find . -type f -iname '*.nef' | |
| 40 | + | } | |
| 41 | + | ||
| 42 | + | main "$@" | |
Plus récent
Plus ancien