Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Iterate through every .jpg or .jpeg file in directory and sub directory

Tags:

ruby

I want to iterate through every jpg/jpeg file in a directory and every subdirectory and every subdirectory of that sub-directory and so on. I want to be able to go through every single image file in a folder. Is there an easy way to do this or would a recursive method work best?

like image 405
Greg Mathews Avatar asked Jun 21 '11 01:06

Greg Mathews


1 Answers

Dir.glob("your_directory/**/*.{jpg,jpeg}")
like image 76
sawa Avatar answered Oct 19 '22 10:10

sawa