On 6/22/06, Peter Bailey <pbailey / bna.com> wrote: > I'm trying to simply lower-case all of the files in a directory. It > doesn't work because RUBY complains about not being able to convert > "nil" to a string. Why in the world is it even including "nil" in my > array? > > files = Dir.glob('*.pdf') > files.each do |file| > File.rename(file, file.downcase!) > end > > It says: > "...can't convert nil into String (Type error)..." I think you're mistaking the source of your error here. Check this out (ri String#downcase!): Downcases the contents of _str_, returning +nil+ if no changes were made. So you're call to +downcase!+ is returning nil in the cases where +file+ was already downcased. When +File.rename+ sees that nil and tries to convert it to a String, it raises the error you see. Try using +String#downcase+ instead (note the lack of the exclamation point). Jacob Fugal