Skip to content

Instantly share code, notes, and snippets.

@kampfgnu
Last active October 8, 2018 15:09
Show Gist options
  • Save kampfgnu/998a9d35af711e6c0f68c1a1a4cd55cd to your computer and use it in GitHub Desktop.
Save kampfgnu/998a9d35af711e6c0f68c1a1a4cd55cd to your computer and use it in GitHub Desktop.
rename files to their creation date
cd $1
for file in *.{JPG,jpg}
do date=$(stat -f %B $file)
dateFormatted=$(date -r $date +%Y-%m-%d' '%H.%M.%S)
mv $file "$dateFormatted.jpg"
done
for file in *.{MOV,mov}
do date=$(stat -f %B $file)
dateFormatted=$(date -r $date +%Y-%m-%d' '%H.%M.%S)
mv $file "$dateFormatted.mov"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment