recursive_directory_listing (function)

recursive_directory_listing(log, baseFolderPath, whatToList='all')[source]

list directory contents recursively.

Options to list only files or only directories.

Key Arguments

  • log – logger

  • baseFolderPath – path to the base folder to list contained files and folders recursively

  • whatToList – list files only, durectories only or all [ “files” | “dirs” | “all” ]

Return

  • matchedPathList – the matched paths

Usage

from fundamentals.files import recursive_directory_listing
theseFiles = recursive_directory_listing(
    log,
    baseFolderPath="/tmp"
)

# OR JUST FILE  

from fundamentals.files import recursive_directory_listing
theseFiles = recursive_directory_listing(
    log,
    baseFolderPath="/tmp",
    whatToList="files"
)

# OR JUST FOLDERS   

from fundamentals.files import recursive_directory_listing
theseFiles = recursive_directory_listing(
    log,
    baseFolderPath="/tmp",
    whatToList="dirs"
)
print theseFiles