Skip to content

Instantly share code, notes, and snippets.

@unicornrainbow
Created January 6, 2011 16:30
Show Gist options
  • Save unicornrainbow/768121 to your computer and use it in GitHub Desktop.
Save unicornrainbow/768121 to your computer and use it in GitHub Desktop.
require 'fileutils'
move_to_dir = ARGV[0] || Time.now.year.to_s
puts <<usage
Project Archiver
======================================================================
Tell me what to do with each entry. Enter nothing to skip.
- Entries which you move will go to #{move_to_dir}.
- Entries which you junk will for to .junk.
ctrl-c to exit at any time.
usage
Dir.foreach(Dir.pwd) do |entry|
unless entry =~ /^\.|^[\d]{4}|#{move_to_dir}/
print "#{entry} (move/junk) or skip: "
case gets.chomp
when /^m(ove)?$/
FileUtils.mv entry, move_to_dir
when /^j(unk)?$/
FileUtils.mv entry, '.junk'
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment