public
Created

  • Download Gist
archive_projects.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
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

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.