Created
June 22, 2009 01:14
-
-
Save jaymcgavren/133747 to your computer and use it in GitHub Desktop.
This file contains 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/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