recursively list files in directory based on fileformat
The snippet can be accessed without any authentication.
Authored by
Magnus Maria Hoffmann
Edited
snippetfile1.txt 310 B
from pathlib import Path
# recursively read in files, only works in python 3.5+
# works on linux & windows returns files w/ directory
def list_files_recursively(directory, fileformat):
glob_path = Path(directory)
file_list = [str(pp) for pp in glob_path.glob("**/*."+fileformat)]
return file_list
Please register or sign in to comment