commit d40a98e02e1c5d0e1c5d52534bbca9924fd132f1 parent 96bffe8d80350e61f0f1c42cb7cac0706cc06a71 Author: hhvn <dev@hhvn.uk> Date: Tue, 1 Jun 2021 22:07:08 +0100 .s/b/imgclean: add image cleaning script Diffstat:
A | .scripts/bin/imgclean | | | 23 | +++++++++++++++++++++++ |
1 file changed, 23 insertions(+), 0 deletions(-)
diff --git a/.scripts/bin/imgclean b/.scripts/bin/imgclean @@ -0,0 +1,23 @@ +#!/bin/sh + +[ -z "$1" ] || [ ! -d "$1" ] || [ ! -z "$2" ] && { + printf "usage: %s <dir>\n" "$(basename $0)" + exit 2 +} + +export IFS=$(printf '\n\t') +for f in $(find . -maxdepth 1 -type f -name "*.JPG") +do + [ "$(uname)" = "OpenBSD" ] && summer=sha256 + [ -z "$summer" ] && summer=sha256sum + + # sum name of file, for speed + sum=$(echo "$f" | $summer | awk '{print $1}') + + # ignore already created + [ ! -f clean/"$sum".jpg ] && { + printf '%s --> %s... ' "$f" "$sum" + exiftool "$f" -all= -o clean/"$sum".jpg >/dev/null + printf 'done\n' + } || printf "%s already exists, ignoring %s...\n" "$sum" "$f" +done