Skip to content

Instantly share code, notes, and snippets.

@laurynas
Created October 1, 2010 21:07
Show Gist options
  • Save laurynas/606866 to your computer and use it in GitHub Desktop.
Save laurynas/606866 to your computer and use it in GitHub Desktop.
Renames all pictures in the folder using EXIF date/time
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