Created
June 30, 2015 15:34
-
-
Save whatalnk/9fbc61900ca1a907f825 to your computer and use it in GitHub Desktop.
Edit Exif data (change date taken)
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 'mini_exiftool' | |
# modified mini_exiftool/examples/shift_time.rb | |
# MiniExiftool.command = 'path/to/exiftool.exe' | |
delta = 60*60*2 # 2 hour | |
# Dir.chdir("./path/to/photos") do | |
Dir.foreach(".") do |f| | |
if f =~ /.+\.JPG$/ then | |
begin | |
photo = MiniExiftool.new(f) | |
rescue MiniExiftool::Error => e | |
$stderr.puts e.message | |
exit -1 | |
end | |
org_time = photo['DateTimeOriginal'] | |
photo['DateTimeOriginal'] = org_time + delta | |
saved = photo.save | |
if saved then | |
fmt = '%Y-%m-%d %H:%M:%S' | |
puts "#{f} changed: #{org_time.strftime(fmt)} -> #{photo['DateTimeOriginal'].strftime(fmt)}" | |
else | |
puts "#{f} could not be changed" | |
end | |
end | |
end | |
# end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment