Skip to content

Instantly share code, notes, and snippets.

@akora
Last active September 30, 2018 17:30
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/80a6bdf2473ed25c9e09caf972f43bef to your computer and use it in GitHub Desktop.
Save akora/80a6bdf2473ed25c9e09caf972f43bef to your computer and use it in GitHub Desktop.
This script renames ( << suggests new filenames) Nikon NEF (RAW) files based on shutter count and date & time information the photos were taken
#!/bin/bash
# This script renames Nikon NEF (RAW) files based on shutter count (EXIF "Shutter Count")
# and date & time information the photos were taken (EXIF "DateTimeOriginal")
# Dependency: exiftool must be installed
# by Andras Kora, ak@akora.info, 2018-09-30 Sun 18:21:19 CEST @723
for file in *.nef ; do
echo -n "Processing $file >> "
exif_shutter_count_info=$(exiftool -ShutterCount -s -s -s "$file")
formatted_shutter_count=$(printf "%08d" $exif_shutter_count_info)
exif_date_time_original_info=$(exiftool -DateTimeOriginal -s -s -s "$file")
date_time_array_split=($exif_date_time_original_info)
formatted_date_original=${date_time_array_split[0]//:/}
formatted_time_original=${date_time_array_split[1]//:/}
formatted_target_filename="$formatted_shutter_count-$formatted_date_original-$formatted_time_original.nef"
echo "Suggested new filename: $formatted_target_filename"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment