Remove folders from output readdir()

Hello everyone,

I have this very stupid question: How can I remove folder names from the output given by readdir()

Lets say I have the following folder structure:

folder1/
|_ file1
|_ file2
|_ file3
|_ folder2/

I get then

julia> readdir()
4-element Vector{String}:
 "file1"
 "file2"
 "file3"
 "folder2"

Is there a way to exclude all folders from the output?

Many thanks in advance,
Olivier

1 Like
filter(!isdir, readdir(; join=true))

perhaps.

4 Likes

Yes indeed!
Thank you so much for the lightning fast answer!

NB:
for reference, here it is shown a good complement to Kristoffer’s solution to be able to display long file lists:

filter(!isdir, readdir(; join=true)) |> x -> show(stdout, "text/plain", x)
1 Like

Thanks for the pointer!

1 Like