Skip to content

Instantly share code, notes, and snippets.

@akora
Created September 29, 2018 15:00
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 akora/dde29866c07a595d1a40100c4f083e6d to your computer and use it in GitHub Desktop.
Save akora/dde29866c07a595d1a40100c4f083e6d to your computer and use it in GitHub Desktop.
This script extracts Shutter Count information from Nikon NEF (RAW) files and saves the output into a CSV file (uses exiftool)
#!/bin/bash
# This script extracts Shutter Count information from Nikon NEF (RAW) files
# and saves the output into a CSV file (for further processing)
# Dependency: exiftool must be installed
# by Andras Kora, ak@akora.info, 2018-09-29 Sat 16:18:37 CEST @638
TIMESTAMP=$(date +%s)
FILENAME=$1
# expecting the CSV file name as an argument
if [[ $# -eq 0 ]] ; then
echo 'This script extracts Shutter Count information from Nikon NEF (RAW) files'
echo 'Please specify the filename of the output CSV file'
exit 0
fi
# Adding header info to the file
echo "Filename,ShutterCount" >> $FILENAME
# Extracting Shutter Count info from NEF (RAW) files
for i in *.nef ; do
echo "Processing $i"
echo -n "$i," >> $FILENAME
exiftool -*shuttercount* -s -s -s "$i" >> $FILENAME
done
# Adding timestamp (as Unix Epoch) to the file's basename
if [[ "$FILENAME" == *csv || *CSV ]] ; then
BASENAME=${FILENAME%????}
mv $FILENAME $BASENAME-$TIMESTAMP.csv
else
mv $FILENAME $FILENAME-$TIMESTAMP.csv
fi
echo "All Done"
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment