Skip to content

Instantly share code, notes, and snippets.

@DeMarko
Created July 1, 2012 06:35
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 DeMarko/3027166 to your computer and use it in GitHub Desktop.
Save DeMarko/3027166 to your computer and use it in GitHub Desktop.
Fix timestamps for JPGs ending in UNIX timestamp
#!/bin/bash
shopt -s nullglob
for f in *.jpg
do
# echo "fixing $f"
timestamp=`echo $f | perl -ne 'm/.*_?\d{4}-\d{2}-\d{2}_(\d+)\.jpg/; print $1'`
if [ $timestamp ]
then
touch_fmt=`date -r $timestamp +%Y%m%d%H%M.%S`
touch -t $touch_fmt $f
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment