Skip to content

Instantly share code, notes, and snippets.

@feklee
Last active January 3, 2021 06:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save feklee/b89b0d152c1ad1554f115ee8d05f79aa to your computer and use it in GitHub Desktop.
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
#!/bin/bash
# Felix E. Klee <felix.klee@inka.de>
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