How to list all files and folders in a folder using Python

We can make use of the glob module to list all files from a folder using Python.


import glob

folder_path = "/data/2023"

file_paths = glob.glob(folder_path + "/*")

for file_path in file_paths:
Display Paths Files and Folders in Python

Facing issues? Have Questions? Post them here! I am happy to answer!

Author Info:

Rakesh (He/Him) is a seasoned developer with over 10 years of experience in web and app development, and a deep knowledge of operating systems. Author of insightful How-To articles for Code2care.

Follow him on: X

You can also reach out to him via e-mail:

Copyright © Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap