Created
January 8, 2016 22:13
-
-
Save thejspr/8cc83e5cccf17cc11af0 to your computer and use it in GitHub Desktop.
Set exif dates on images based on their filename
This file contains hidden or 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 'time' | |
# Files with a name like "2010-12-08 12.34.20.png" gets their | |
# exif dates set to that time. | |
files = Dir.glob('*.*g') | |
files.each do |file| | |
date = file.to_s[0...file.to_s.length-4] | |
time = Time.parse(date.gsub('.', ':')) | |
formatted_date = time.strftime("%Y:%m:%d %H:%M:%S") | |
cmd = "exiftool -AllDates='#{formatted_date}' -overwrite_original '#{file}'" | |
system(cmd) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment