Monday, 7 December 2020

Python 3.6 glob include hidden files and folders

I try to loop over all files matching a certain extension, including those inside hidden folders. So far I haven't found a way to do this with iglob. This works for all folder except those starting with a dot:

import glob
for filename in glob.iglob('/path/**/*.ext', recursive=True):
    print(filename)

I have tried to add the dot as an optional character to no avail. I'd really like to use glob instead of residing to os.walk.

How to include all files/folders, even those starting with ., with glob?



from Python 3.6 glob include hidden files and folders

No comments:

Post a Comment