Skip to content

Instantly share code, notes, and snippets.

@thinkerbot
Created November 24, 2016 20:24
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 thinkerbot/926c10b9811b4b067d55fbd07b74f343 to your computer and use it in GitHub Desktop.
Save thinkerbot/926c10b9811b4b067d55fbd07b74f343 to your computer and use it in GitHub Desktop.
Google Uploader
#!/bin/bash
# Google Uploader looks at a file timestamp not the video metadata. Run
# this to get the right timestamp to appear on the video. Requires
# exiftool. https://productforums.google.com/forum/#!topic/photos/oj96JZK14Fs
#
# brew install exiftool
# ./fix_timestamps.sh
#
cd "DIR_WITH_THE_m4v_VIDEO_FILES"
ruby -rtime -ryaml -rshellwords -e '
files = ARGV.dup
ARGV.clear
metadata = `exiftool -j #{Shellwords.shelljoin(files)}`
data = YAML.load(metadata)
files.zip(data).each do |file, data|
rawdate, rawtime = data["CreationDate"].split(" ")
creation_date = Time.parse "#{rawdate.tr(":", "/")}T#{rawtime}"
puts "utime: #{creation_date.iso8601} #{file}"
File.utime(creation_date, creation_date, file, file)
end
' *.m4v
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment