How can I get the number of files in a certain folder using pathlib ?
from pathlib import Path
fileDir = Path("C:/Users/Jonas/Desktop/Test")
You could use .glob()
or .rglob()
:
from pathlib import Path
fileDir = Path("C:/Users/Jonas/Desktop/Test")
excelFiles = fileDir.rglob('*.xl*')
print(len(list(excelFiles)))
>>> 3