rubyfile-ionaming

systematically changing filenames in a directory w/ Ruby


I'd like to grab all the files in a particular directory, and then apply a gsub(/abc/,'z') to all the filenames and essentially resave the files under the new filenames, how do I do that?

I've been looking at File but I don't seem to have any of the parameters that it requires, aka the filename, etc.

M


Solution

  • File.rename(from, to) along with Dir.entries (or Dir.foreach)?