Does anyone know if there's an existing module/function inside Ruby to traverse file system directories and files? I'm looking for something similar to Python's os.walk
. The closest module I've found is Find
but requires some extra work to do the traversal.
The Python code looks like the following:
for root, dirs, files in os.walk('.'):
for name in files:
print name
for name in dirs:
print name
Dir[foo].each { bar }
, you can useDir.glob(foo) { bar }
which will iterate over all the files matching the block without creating a temporary array first. – Crusty