I need ruby code where i can loop throught a list of folders and then loop through each image individually in that folder
by grabing the pictures file and its name,
I know Dir.foreach is great to get the folder names but how do I get the pictures
I need ruby code where i can loop throught a list of folders and then loop through each image individually in that folder
by grabing the pictures file and its name,
I know Dir.foreach is great to get the folder names but how do I get the pictures
If I understand you correctly, you want a list of each file if it's an image?
If your images are all the same format, IE .jpg, you could use:
folder_results = Dir.foreach("your_folder_name") {|x| File.extname(x) }
for file in folder_results
if (file === '.jpg')
# do something
end
end
If you run following code from the base directory of your file structure, then it will list all files ending in ".jpg" or ".png".
Dir.glob("./**/*.{jpg,png}").each do |file|
puts file
end