Iterate through each .jpg or .jpeg file in a directory and subdirectory

I want to iterate over every jpg / jpeg file in a directory and in every subdirectory and in any subdirectory of this subdirectory and so on. I want to be able to view each image file in a folder. Is there an easy way to do this or a better recursive method?

+5
source share
1 answer
Dir.glob("your_directory/**/*.{jpg,jpeg}")
+8
source

All Articles