From: Jim Freeze Date: 2003-10-02T19:19:20+09:00 Subject: Re: Getting a list of the files in a directory On Thursday, 2 October 2003 at 12:24:25 +0900, Revision17 wrote: > Hi, I'm just starting out with ruby and I'm writing a script to rename > a bunch of files in a directory to a way I want them to be (just to > get more familiar). I've looked at the documentation for the file > class (http://www.rubycentral.com/book/ref_c_file.html), but I can't > seem to find the method I'd use to get all the names of files in a > directory. How can I do this? The easy way is to use the glogging feature of Dir#[]. For example files = Dir["*"] To upcase all files in a directory, do: Dir["*"].each { |file| `mv #{file} #{file.upcase}` } for unix. It's similar for windows, but I don't have a windows box to test it. -- Jim Freeze ---------- Hofstadter's Law: It always takes longer than you expect, even when you take Hofstadter's Law into account.