From: "Bashar A. Asad" Date: 2001-12-22T09:06:39+09:00 Subject: [ruby-talk:29273] Re: upper case to lower On Saturday 22 December 2001 02:47, you wrote: > Hello, > > At Sat, 22 Dec 2001 08:00:08 +0900, > > Bashar A. Asad wrote: > > am trying to write a script that will read in all the file names in dir X > > and convert the upper case letters to lower case. How can do such thing > > in ruby? > > There are some ways. > > Dir.entries(X).each do |f| > (n = f.dup).downcase! and File.rename(File.join(X, f), File.join(X, n)) > end > okey I don't understand the "!" part why do u have it > Dir.open(X) do |d| > d.each do |f| > (n = f.dup).downcase! and File.rename(File.join(X, f), File.join(X, n)) > end > end > > # differs a bit > Dir.glob(File.join(X, "*")) do |f| > d, n = File.split(f) > n.downcase! and File.rename(f, File.join(d, n)) > end > > > Nobu Nakada