Skip to content

Instantly share code, notes, and snippets.

@pokutuna
Created February 8, 2011 22:55
Show Gist options
  • Save pokutuna/817472 to your computer and use it in GitHub Desktop.
Save pokutuna/817472 to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
raise ArgumentError unless ARGV.size >= 2
def prompt(message)
puts "#{message} [Y/n]"
answer = STDIN.gets.chomp
answer == 'Y' ? true : false
end
root_dir = File.join(ARGV.shift, "**/")
patterns = ARGV
patterns.each do |pat|
paths = Dir.glob(root_dir + pat).to_a
puts paths
if prompt "delete them? (#{paths.size} files)" then
paths.each{ |p| File.delete p}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment