Skip to content

Instantly share code, notes, and snippets.

@mmmaly
Created March 13, 2014 22:20
Show Gist options
  • Save mmmaly/9538281 to your computer and use it in GitHub Desktop.
Save mmmaly/9538281 to your computer and use it in GitHub Desktop.
rename images and videos according to their creation time
#!/bin/bash
#rename iPhone image/video files
#use only for tagged files
for i in *.mov
do
TIME=`exiftool "$i" | grep "Media Create Date" | sed -e 's/Media Create Date *: //'`
TOUCHTIME=`echo $TIME | sed -e 's/:/-/;s/:/-/;'`
FILENAME=`echo $TIME | sed -e 's/:/-/g;s/ /_/'`
touch -d "$TOUCHTIME" "$i"
EXT=${i##*.}
mv -i -v "$i" "$FILENAME"."$EXT"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment