Friday, April 27, 2012

How to list all files with a given extension in Ruby

Dir["*.xml"].each do {|f| p f}

Dir will return all xml files as an array. The block prints the name of the xml file.