Last active
January 3, 2021 06:04
-
-
Save feklee/b89b0d152c1ad1554f115ee8d05f79aa to your computer and use it in GitHub Desktop.
Finds developed photos, i.e. ones where there is a raw file and at least one JPEG file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Felix E. Klee <[email protected]> | |
shopt -s nullglob | |
# Usage info | |
show_help() { | |
cat << EOF | |
Usage: ${0##*/} TARGET_DIR | |
Find developed photos, i.e. ones where there is a raw file and at | |
least one JPEG file. Move all corresponding files into TARGET_DIR. | |
Tested with the Ricoh GRIII. | |
EOF | |
} | |
if [ "$#" -ne 1 ]; then | |
show_help >&2 | |
exit 1 | |
fi | |
TARGET_DIR="$1" | |
if [ ! -d "$TARGET_DIR" ]; then | |
echo "Directory does not exist: $TARGET_DIR" >&2 | |
exit 1 | |
fi | |
JPEG_COUNTS=$(mktemp) | |
exiftool -q -s -s -s -shuttercount *.jpg *.JPG | sort >"$JPEG_COUNTS" | |
RAW_COUNTS=$(mktemp) | |
exiftool -q -s -s -s -shuttercount *.dng *.DNG | sort >"$RAW_COUNTS" | |
DEVELOPED_COUNTS=$(mktemp) | |
comm -12 "$JPEG_COUNTS" "$RAW_COUNTS" >"$DEVELOPED_COUNTS" | |
for a in *.jpg *.JPG *.jpeg *.dng *.DNG | |
do | |
COUNT=$(exiftool -s -s -s -shuttercount "$a") | |
if grep -Fxq "$COUNT" "$DEVELOPED_COUNTS" | |
then | |
mv -i "$a" "$TARGET_DIR" | |
fi | |
done | |
C=$(cat "$DEVELOPED_COUNTS" | wc -l) | |
echo $C developed photos found and moved to: $TARGET_DIR |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment