This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Jun 14th, 2013  |  syntax: Ruby  |  size: 0.28 KB  |  views: 21  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. def batchrename(annoyingstr)
  2.   Dir["#{Dir.pwd}/*"].each do |name|
  3.     new_name = name.gsub(annoyingstr, "")
  4.     puts "Renaming #{name} to #{new_name}"
  5.     File.rename(name, new_name)
  6.   end
  7. end
  8.  
  9. def listcwd
  10.   Dir.foreach("#{Dir.pwd}") do |fname|
  11.     puts fname
  12.   end
  13. end
clone this paste RAW Paste Data