List of All Files With Specific Extensions in Directory (Python Example)

Published: 28 July 2020
on channel: Data Science Garage
3,758
63

How to make a list of files with specific extensions (for example images, video, documents, etc.) in a directory by using Python. The result is: a file list (list variable in Python) containing all filenames found on all included subdirectories of root folder with needed extensions, such as JPG, PNG, JPEG, etc.

For this tutorial I used only Python os module (no glob). That's it! And one simple Python procedure make all the magic. Explanation is in video.

In video example I choose to try example of extracting all filenames of images from all subdirectories found in root directory. Example root directory - caltech101

Hoping it will help to data scientist or data analyst who working with local data or want to pre-process big amount of data for machine learning, deep learning or a simple data science project.

#pythonprogramming
#pythontutorial
#pythontricks


Watch video List of All Files With Specific Extensions in Directory (Python Example) online without registration, duration hours minute second in high quality. This video was added by user Data Science Garage 28 July 2020, don't forget to share it with your friends and acquaintances, it has been viewed on our site 3,758 once and liked it 63 people.