From: Peter Bailey Date: 2009-12-15T01:47:26+09:00 Subject: Re: one-liner for lowercasing files Thanks, Brian. Yes, it's just filename I want, not content. But, this is what I get when I try your suggestion: >ruby Dir.glob("*").each { |fn| File.rename(fn, fn.downcase) } 'file' is not recognized as an internal or external command, operable program or batch file. Brian Candler wrote: > Peter Bailey wrote: >> Can someone please suggest a simple Ruby one-liner to lowercase a >> filename (in a directory)? > > Lowercase the *contents* of a file, or its *name* ? > > For the contents, this example lifted almost verbatim from "man ruby". > > ruby -p -i.bak -e '$_.downcase!' /tmp/junk > > To lowercase the names of all files: > > Dir["*"].each { |fn| File.rename(fn, fn.downcase) } > > Beware that even ruby 1.9 won't lowercase anything other than plain A-Z. -- Posted via http://www.ruby-forum.com/.