How to iterate through a folder?
Question:
Unfortunately, I do not have any code for this, because I don’t know how this would be done.
What I want to do is iterate through a folder (not directory) (named "images") and get all the images from that folder (not directory). Since these images will be added through a discord bot, I do not know how many images will be in that folder (not directory).
Answers:
try this
import glob
glob.glob("path/to/folder/*.jpg")
you may change the file format to .png or any format you are using.
Unfortunately, I do not have any code for this, because I don’t know how this would be done.
What I want to do is iterate through a folder (not directory) (named "images") and get all the images from that folder (not directory). Since these images will be added through a discord bot, I do not know how many images will be in that folder (not directory).
try this
import glob
glob.glob("path/to/folder/*.jpg")
you may change the file format to .png or any format you are using.