Created
October 1, 2010 21:07
-
-
Save laurynas/606866 to your computer and use it in GitHub Desktop.
Renames all pictures in the folder using EXIF date/time
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 'rubygems' | |
require 'exifr' | |
data = Dir.glob("photos/*.jpg").collect do |file| | |
{ | |
:file => file, | |
:time => EXIFR::JPEG.new(file).date_time, | |
} | |
end | |
data = data.sort_by { |item| item[:time] } | |
data.each do |item| | |
t = item[:time].strftime("%y%m%d_%H%M%S") | |
name = "photos/photo_#{t}.jpg" | |
p name | |
File.rename(item[:file], name) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment