What is the simplest way to get the full recursive list of files inside a folder with python? I know about os.walk()
, but it seems overkill for just getting the unfiltered list of all files. Is it really the only option?
pathlib.Path.rglob
is pretty simple. It lists the entire directory tree
(The argument is a filepath search pattern. "*"
means list everything)
import pathlib
for path in pathlib.Path("directory_to_list/").rglob("*"):
print(path)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With