Skip to content

Instantly share code, notes, and snippets.

@BostjanOb
Last active June 13, 2016 12:16
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 BostjanOb/f4f9ae940908bd3dd2196fdbd18e7045 to your computer and use it in GitHub Desktop.
Save BostjanOb/f4f9ae940908bd3dd2196fdbd18e7045 to your computer and use it in GitHub Desktop.
Change EXIF from filename
#!/bin/bash
# Required: http://www.sentex.net/~mwandel/jhead/
# filename format: YYYYMMDD_HHMMSS.jpg
for filename in $(find . -maxdepth 1 -regextype posix-extended -iregex ".*\/.{8}_.{6}.jpg" -type f); do
YEAR=$(echo $filename| cut -c 3-6)
MONTH=$(echo $filename| cut -c 7-8)
DAY=$(echo $filename| cut -c 9-10)
HOUR=$(echo $filename| cut -c 12-13)
MINUTE=$(echo $filename| cut -c 14-15)
SECOND=$(echo $filename| cut -c 16-17)
COMBINED="$YEAR:$MONTH:$DAY-$HOUR:$MINUTE:$SECOND"
jhead -ts$COMBINED $filename
done
# filename format: IMG_YYYYMMDD_HHMMSS.jpg
for filename in $(find . -maxdepth 1 -regextype posix-extended -iregex ".*\/IMG_.{8}_.{6}.jpg" -type f); do
YEAR=$(echo $filename| cut -c 7-10)
MONTH=$(echo $filename| cut -c 11-12)
DAY=$(echo $filename| cut -c 13-14)
HOUR=$(echo $filename| cut -c 16-17)
MINUTE=$(echo $filename| cut -c 18-19)
SECOND=$(echo $filename| cut -c 20-21)
COMBINED="$YEAR:$MONTH:$DAY-$HOUR:$MINUTE:$SECOND"
jhead -ts$COMBINED $filename
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment