Skip to content

Instantly share code, notes, and snippets.

@jobwat
Created April 8, 2015 05:42
Show Gist options
  • Save jobwat/dc6479f20e0f74e10e0d to your computer and use it in GitHub Desktop.
Save jobwat/dc6479f20e0f74e10e0d to your computer and use it in GitHub Desktop.
Shift the datetime of files according to the sample gap
ref_file=GOPR3440.MP4
new_time_for_that_file=0327160015 #date's format: 27th March 2015, 16:00
ref_file_timestamp=`stat -f %B -t %s "$ref_file"`
new_time_timestamp=`date -j $new_time_for_that_file +%s`
time_diff=$[$new_time_timestamp - $ref_file_timestamp]
for f in *; do
old=$(stat -f %B -t %s "$f")
new=$(date -r $(($old + $time_diff)) '+%m/%d/%Y %H:%M:%S')
SetFile -d "$new" -m "$new" "$f"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment