Top Level Namespace
- Includes:
- FileUtils::Verbose
Instance Method Summary collapse
Instance Method Details
#rmv(re, target) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/rmv.rb', line 4 def rmv(re, target) files = Dir["**/*"].map do |path| if path =~ re [path, path.sub(re, target)] else nil end end.compact uniq_files = files.map{|f| f.last}.uniq if uniq_files.length != files.length (files.map{|f| f.last} - uniq_files).uniq abort "targets are not unique: #{(files - uniq_files).uniq.inspect}" end files.each do |from, to| mv from, to end end |