import os
import glob
def find_all_files_with_ext(ext):
pattarn = '*' + os.extsep + ext
return glob.glob(pattarn)
import os
def _find_all_files_with_ext(dir, ext):
suffix = os.extsep + ext.lower()
for root, dirs, files in os.walk(dir):
for file in files:
if file.lower().endswith(suffix):
yield os.path.join(root, file)
def find_all_files_with_ext(dir, ext):
return list(_find_all_files_with_ext(dir, ext))
Recommended Posts