anzahl files in directory python code example
Example 1: iterate through all files in directory python
import os
directory = 'the/directory/you/want/to/use'
for filename in os.listdir(directory):
if filename.endswith(".txt"):
#do smth
continue
else:
continue
Example 2: python get files in directory
from pathlib import Path
for txt_path in Path("/path/folder/directory").glob("*.txt"):
print(txt_path)