Links

Get all files from directory

Tags: #python #naas #glob #pprint #snippet
Description: This notebook gives you the ability to get all files from a directory even in a sub-directory.

Input

Import libraries

import glob
from os import path

Setup Variables

dir_path = "" # If dir path is "", it will returned files from current folder

Model

Get all files

files = glob.glob(path.join(dir_path, "**"), recursive=True)

Output

Dislay result

print(f"Total files and folders fetched:", len(files))
sorted(files)