How do I write a loop in ruby so that I can execute a block of code on each file?
I\'m new to ruby, and I\'ve concluded that the way to do this is a do each loop.
I like this one, that hasn't been mentioned above.
require 'pathname' Pathname.new('/my/dir').children.each do |path| puts path end
The benefit is that you get a Pathname object instead of a string, that you can do useful stuff with and traverse further.