Python – list all file paths recursively

less than 1 minute read

List all file paths recursively

1
2
3
4
5
6
7
8
9
import os

def get_all_file_paths(path):
    # r=root, d=directories, f = files
    files = []
    for r, d, f in os.walk(path):
        for file in f:
            files.append(os.path.join(r, file))
    return files

Categories:

Updated: