Class: ExifDateSorter
- Inherits:
-
Object
- Object
- ExifDateSorter
- Defined in:
- lib/exif-date-sorter.rb,
lib/exif-date-sorter/version.rb
Constant Summary collapse
- VERSION =
"0.0.2"
Instance Method Summary collapse
- #date(image) ⇒ Object
- #dir(image) ⇒ Object
-
#initialize(source, target) ⇒ ExifDateSorter
constructor
A new instance of ExifDateSorter.
- #move ⇒ Object
Constructor Details
#initialize(source, target) ⇒ ExifDateSorter
Returns a new instance of ExifDateSorter.
7 8 9 10 |
# File 'lib/exif-date-sorter.rb', line 7 def initialize(source, target) @source = source @target = target end |
Instance Method Details
#date(image) ⇒ Object
20 21 22 |
# File 'lib/exif-date-sorter.rb', line 20 def date(image) EXIFR::JPEG.new(image).date_time_original end |
#dir(image) ⇒ Object
24 25 26 27 |
# File 'lib/exif-date-sorter.rb', line 24 def dir(image) date = date(image) "#{@target}/#{date.year}/#{'%02d' % date.month}" end |
#move ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/exif-date-sorter.rb', line 12 def move Dir[@source + '/**/*.{jpg,JPG}'].each do |image| target_dir = dir(image) FileUtils.mkdir_p(target_dir) unless File.directory? target_dir FileUtils.move image, target_dir end end |