Skip to content

Instantly share code, notes, and snippets.

@julesjans
Created November 17, 2016 10:45
Show Gist options
  • Save julesjans/9f3a7174955cbac51c45dedb1a5de1e2 to your computer and use it in GitHub Desktop.
Save julesjans/9f3a7174955cbac51c45dedb1a5de1e2 to your computer and use it in GitHub Desktop.
Renames images according to their date
#!/bin/bash
#
# Image renaming script, requires exiftool
for f in "${1%/}"/*.{jpg,jpeg}
do
if [ -f "$f" ]
then
echo "Preparing $f"
filename=$(basename "$f")
dirname=$(dirname "$f")
newname=$(exiftool -createdate "$f" | grep -o '[0-9:]*\s[0-9:]*$' | sed 's/[^0-9]/-/g')
echo "Completed $dirname/$newname.jpg"
mv "$f" "$dirname/$newname.jpg"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment