little photo organizer

Place this script in a folder full of pictures, run it, and it will organize the pictures into folders by the day they were taken.

Run it as: ruby photo_organizer.rb

Code:

#photo_organizer.rb

require 'fileutils'

def fileShortDate(fich)
dt = File.mtime(fich)
dt.strftime("%d-%m-%Y")
end

def isImagem(fich)
File.extname(fich).upcase == ".JPG" or File.extname(fich).upcase == ".PNG"
end

print "Creating dirs "
Dir.foreach(".") { |x| Dir.mkdir(fileShortDate(x)) and print(".") if (isImagem(x)) unless File.directory?(fileShortDate(x)) }

print "\nCopying pics "
Dir.foreach(".") { |x| FileUtils.mv(x, fileShortDate(x)+'/'+x) and print(".") if (isImagem(x)) }

Doing Javascript

with Ruby...

me likes the idea... With a higher level UI framework on top could be a new solution for platform independent ruby UI's.