Created
October 30, 2019 11:13
-
-
Save giasuddin90/42b0dce8d4a0eb8f34ae675264f80b0c to your computer and use it in GitHub Desktop.
Python read file from a directory by using file extension
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__author__ = 'giasuddin' | |
import os | |
import fnmatch | |
images = ['*.css', '*.jpeg', '*.ico', '*.gif', '*.png'] | |
file_path= '/home/giasuddin/pyramid_sites/test//css' | |
for (dirpath, dirnames, filenames) in os.walk(file_path): | |
for extensions in images: | |
for filename in filenames: | |
if fnmatch.fnmatch(filename, extensions): | |
print(filename) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment