How to return a collection of files from a given directory in Elixir?
You're looking for Path.wildcard/2
:
iex(1)> Path.wildcard("/tmp/some/dir/path/*.rb")
["/tmp/some/dir/path/bar.rb", "/tmp/some/dir/path/baz.rb",
"/tmp/some/dir/path/foo.rb"]
iex(2)> Path.wildcard("/tmp/**/*b*.rb")
["/tmp/some/dir/path/bar.rb", "/tmp/some/dir/path/baz.rb"]
And if you want to recursively gather files with a regex, there's :filelib.fold_files/5
.