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) has over 14+ years of experience in Web and Application development. He is the 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