Include all files from folder

Hello,
I can import a file into the Julia environment with include("path/file.jl"). Is it possible to include all the files present in “path”? include("path/*.jl") does not work…
Thanks

You could use

include.(filter(contains(r".jl$"), readdir(dir; join=true)))

which lists the absolute pathes of all files in dir, filters for files with end with .jl and includes them one by one.

2 Likes

For a wildcard-based solution (and if you’re willing to add a dependency for this), you can use the Glob package:

foreach(include, glob("*.jl", dir))
2 Likes

Note that this works only if the files are independent since the order of the includes may vary between systems. To save you future headache I suggest that you list the includes explicitly.

5 Likes