Skip to content

Instantly share code, notes, and snippets.

@colinbm
Last active December 14, 2015 12:59
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 colinbm/5090553 to your computer and use it in GitHub Desktop.
Save colinbm/5090553 to your computer and use it in GitHub Desktop.
Correct the creationtime of photos based on EXIF data.
require 'exifr'
files = Dir['**/*']
files.each do |file|
if File.file?(file) && File.extname(file).downcase == '.jpg'
begin
exif = EXIFR::JPEG.new(file)
if !exif.date_time_original.nil?
File.utime(exif.date_time_original, exif.date_time_original, file)
end
rescue
puts "#{file} - #{$!}"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment