Last active
December 14, 2015 12:59
-
-
Save colinbm/5090553 to your computer and use it in GitHub Desktop.
Correct the creationtime of photos based on EXIF data.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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