You can use the function glob.glob() or glob.iglob() directly from glob module to retrieve paths recursively from inside the directories/files and subdirectories/subfiles.
16 glob.glob () is a wrapper around os.listdir () so the underlaying OS is in charge for delivering the data. In general: you can not make an assumption on the ordering here. The basic assumption is: no ordering. If you need some sorting: sort on the application level.
Is there a better way to use glob.glob in python to get a list of multiple file types such as .txt, .mdown, and .markdown? Right now I have something like this: projectFiles1 = glob.glob( os.path...
The expression path = r'.\**\*' means that the glob module will search for files in current directory recursively (recursive=True). You may also have to remove one backslash and an asterisk from path if there are no subdirectories in the folder.
Until recently the glob module did not support recursive matching and there's a lot of code out there that may have used ** in patterns thus the Python core developers didn't want to break such code.
The pattern rules for glob are not regular expressions. Instead, they follow standard Unix path expansion rules. There are only a few special characters: two different wild-cards, and character ranges are supported [from pymotw: glob – Filename pattern matching]. So you can exclude some files with patterns. For example to exclude manifests files (files starting with _) with glob, you can use: