Skip to content

Instantly share code, notes, and snippets.

@ArthurDelannoyazerty
Last active March 20, 2024 10:01
Show Gist options
  • Save ArthurDelannoyazerty/4ee434e0f7029fc1382ca2a1dbfa345b to your computer and use it in GitHub Desktop.
Save ArthurDelannoyazerty/4ee434e0f7029fc1382ca2a1dbfa345b to your computer and use it in GitHub Desktop.
Find files with the corresponding extension in the selected folder and its subdirectories. Return the list of files paths
def find_files_recursive_folder(folder_path:str, file_extension:str) -> list:
list_filepath = list()
for dirpath, _, filenames in os.walk(folder_path):
for filename in [f for f in filenames if f.endswith(file_extension)]:
filepath = dirpath.replace("\\","/") + "/" + filename
list_filepath.append(filepath)
return list_filepath
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment