I get that I can use glob.glob("./**/*") but this seems to include the directory names in the result set. If I try glob.glob("./**/*.*") instead, it excludes files that do not have any file extensions. How do I get a result set that gives all the files irrespective of file extension?
Asked
Active
Viewed 61 times
-2
tinkuge
- 97
- 1
- 11
-
You know that filenames don't have to be of the form xxx.yyy and that folder names can be of the form xxx.yyy, yes? – jarmod May 26 '21 at 18:14
-
@jarmod I hadn't considered that. In that case, ```glob.glob("./**/*.*")``` would pick up those results as well – tinkuge May 26 '21 at 18:16
-
Or [Python recursive folder read](https://stackoverflow.com/q/2212643/6045800) – Tomerikoo May 26 '21 at 18:16
1 Answers
1
folderpath = ''
for dirname, subdirs, files in os.walk(folderpath):
for fname in files:
full_path = os.path.join(dirname, fname)
print(dirname)
print(fname)
print(full_path)
Tomerikoo
- 15,737
- 15
- 35
- 52
killersquid
- 51
- 4