Skip to content

Instantly share code, notes, and snippets.

@tzvetkoff
Created August 16, 2012 15:53
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 tzvetkoff/3371275 to your computer and use it in GitHub Desktop.
Save tzvetkoff/3371275 to your computer and use it in GitHub Desktop.
kombinator.rb
#!/usr/bin/env ruby
require 'fileutils'
require 'exifr'
Dir['Photos/*.*'].each { |filename|
source = "#{Dir.pwd}/#{filename}"
destination = nil
begin
EXIFR::JPEG.new(source).tap { |exif|
destination = "#{Dir.pwd}/Library/#{exif.date_time.strftime('%Y/%b/%d')}/#{File.basename(filename)}" if exif.date_time
}
rescue
# not an image - ignore
else
destination = "#{Dir.pwd}/Library/Sometime/#{File.basename(filename)}" if destination.nil?
FileUtils.mkdir_p(File.dirname(destination))
File.rename(source, destination)
end
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment