I have a folder containing files in different types. I only need to deal with image files (jpg, png, jpeg, JPG, ...). For that, I use glob.glob
to get only files with 'jpg', 'png', ... extensions.
The problem is that I have to use glob.glob
many times (as much as the image extensions number) to get all the images:
import glob
images = glob.glob('tests/*.jpg') + glob.glob('tests/*.jpeg') + glob.glob('tests/*.png') + glob.glob('tests/*.JPG')
Is there a way to use glob.glob
in a more optimized form (something like glob.glob('path/*.{'jpg', 'png', 'jpeg', 'JPG'}
) or is there a simpler function to use it instead of glob
?