Created
November 3, 2013 19:24
-
-
Save gaygenius/7293776 to your computer and use it in GitHub Desktop.
Group photos that are grouped in date directories into month directories
This file contains hidden or 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
#!/usr/bin/env ruby -w | |
require 'fileutils' | |
Dir.chdir('/users/josecapo/Pictures') | |
months = Dir['201?-??-??'].map {|date| date[0..6]}.uniq | |
months.each do |month| | |
FileUtils.mkdir_p(month) | |
Dir["#{month}-*"].each do |date| | |
FileUtils.mv(Dir["#{date}/*.JPG"], month) | |
FileUtils.mv(date, '/tmp') | |
puts "#{date}/*.JPG => #{month}" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment