Skip to content

Instantly share code, notes, and snippets.

@jaymcgavren
Created June 22, 2009 00:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jaymcgavren/133738 to your computer and use it in GitHub Desktop.
Save jaymcgavren/133738 to your computer and use it in GitHub Desktop.
#!/usr/bin/ruby
require 'fileutils'
require 'exifr'
ARGV.each do |file|
begin
date = EXIFR::JPEG.new(file).date_time_original
dir = sprintf('%04d-%02d-%02d', date.year, date.month, date.mday)
Dir.mkdir(dir) unless File.exist?(dir)
FileUtils.mv(file, dir)
rescue => exception
abort "Error processing #{file}: " + exception.message + "\n" + exception.backtrace.join("\n")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment