Skip to content

Instantly share code, notes, and snippets.

@youchen
Last active September 5, 2017 03:53
Show Gist options
  • Save youchen/3d181aecb3b022ff3f7a6a08fdfdd70b to your computer and use it in GitHub Desktop.
Save youchen/3d181aecb3b022ff3f7a6a08fdfdd70b to your computer and use it in GitHub Desktop.
Script to shift the timestamp of file.
# source: https://morimori.tokyo/2015/10/adjusting-timestamps-from-a-gopro/
#
#!/usr/bin/env bash
FILES=$(ls *.MP4) # FILES=$(ls *.{JPG,MP4})
for filename in $FILES
do
# Offset is 974 days 10 hours 39 minutes
NEWDATE=$(date -j -v+974d -v+10H -v+39M -f "%m/%d/%Y %H:%M:%S" "$(GetFileInfo -m $filename)" +"%m/%d/%Y %H:%M:%S")
echo $filename - $NEWDATE
# Adjust modification time:
SetFile -m "$NEWDATE" "$filename"
# Adjust creation date
SetFile -d "$NEWDATE" "$filename"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment