Friday, April 27, 2012

How to list all files in a directory in Ruby

Dir.foreach(".") do {|f| p f}

This will print all the file names in the current directory including files that begin with a period.