Iterate through every file in one directory

Posted by Andrew on Stack Overflow See other posts from Stack Overflow or by Andrew
Published on 2010-03-24T23:43:13Z Indexed on 2010/03/24 23:53 UTC
Read the original article Hit count: 251

Filed under:
|

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.

The ruby file will be executed from a different directory than the directory I want to loop through.

I've tried the Dir.foreach and I couldn't get it to work.

© Stack Overflow or respective owner

Related posts about ruby

Related posts about directory