I have insane big directory. I need to get filelist via python.
In code i need to get iterator, not list. So this not work:
os.listdir
glob.glob (uses listdir!)
os.walk
I cant find any good lib. help! Maybe c++ lib?
To get a list of all the files and folders in a particular directory in the filesystem, use os. listdir() in legacy versions of Python or os. scandir() in Python 3.
listdir() method gets the list of all files and directories in a specified directory. By default, it is the current directory.
for python 2.X
import scandir
scandir.walk()
for python 3.5+
os.scandir()
https://www.python.org/dev/peps/pep-0471/
https://pypi.python.org/pypi/scandir
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