Skip to content

Instantly share code, notes, and snippets.

@martinos
Last active December 17, 2015 19:19
Show Gist options
  • Save martinos/5659775 to your computer and use it in GitHub Desktop.
Save martinos/5659775 to your computer and use it in GitHub Desktop.
def find_file_created_at(base_dir, time_range)
Dir["#{base_dir}/**/*"].select { |f| File.file?(f) && time_range.cover?(File.ctime(f)) }.map{|f| [File.ctime(f), f]}
end
time_range = Time.new(2011,5,5)..Time.new(2011,5,12)
files = find_file_created_at('.', time_range);1
require 'fileutils'
files.each do |time, file|
new_file = File.join('c:\\Users\\Madame YonKa\\nic_music\\', file)
dir = File.dirname(new_file)
FileUtils.mkdir_p(dir)
FileUtils.mv(file, new_file)
end;1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment