1

I am new to Julia, and beginning to port some machine learning projects over to Julia. One thing I am missing is the python os library which can walk a directory path quite easily. I am googling around and looks like it doesn't exist in Julia yet.. but wanted to throw up a question before I start writing my own implementation

for context here's the python function I'm porting

import os
import fnmatch

def list_all_files(directory, extensions=None):
    for root, dirnames, filenames in os.walk(directory):
        for filename in filenames:
            base, ext = os.path.splitext(filename)
            joined = os.path.join(root, filename)
            if extensions is None or ext.lower() in extensions:
                yield joined
chepner
  • 497,756
  • 71
  • 530
  • 681
Erik
  • 2,782
  • 3
  • 34
  • 64

1 Answers1

3

Have a look at walkdir. You can also use readdir(), maybe in combination with filter().

Example:

for d in filter(isdir, readdir())
    println("I'm a directory: ", d)
end
carstenbauer
  • 9,817
  • 1
  • 27
  • 40