Skip to content

Latest commit

 

History

History
43 lines (25 loc) · 1.51 KB

Python_Get_all_files_from_directory.md

File metadata and controls

43 lines (25 loc) · 1.51 KB



Template request | Bug report | Generate Data Product

Tags: #python #naas #glob #pprint #snippet

Author: Ayoub Berdeddouch

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)