Skip to content

Instantly share code, notes, and snippets.

@gaygenius
Created November 3, 2013 19:24
Show Gist options
  • Save gaygenius/7293776 to your computer and use it in GitHub Desktop.
Save gaygenius/7293776 to your computer and use it in GitHub Desktop.
Group photos that are grouped in date directories into month directories
#!/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