Skip to content

Instantly share code, notes, and snippets.

@jaymcgavren
Created June 22, 2009 01:14
Show Gist options
  • Save jaymcgavren/133747 to your computer and use it in GitHub Desktop.
Save jaymcgavren/133747 to your computer and use it in GitHub Desktop.
#!/usr/bin/ruby
require 'fileutils'
ARGV.each do |file|
begin
date = File.new(file).mtime
dir = sprintf('%04d-%02d-%02d', date.year, date.month, date.mday)
Dir.mkdir(dir) unless File.exist?(dir)
FileUtils.mv(file, dir)
rescue => exception
abort "Error processing #{file}: " + exception.message + "\n" + exception.backtrace.join("\n")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment