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).
Asked
Active
Viewed 41 times
0
-
https://docs.python.org/3/library/glob.html – BeRT2me Oct 09 '22 at 00:06
-
Welcome to Stack Overflow. Please read [ask], and [please try](https://meta.stackoverflow.com/questions/261592) to look for existing solutions before posting. It is [as easy as writing `python` and then copying and pasting your question title after that, into a search engine](https://duckduckgo.com/?q=python+How+to+iterate+through+a+folder%3F). – Karl Knechtel Oct 09 '22 at 00:13
-
Did you try clicking the long link in my comment? – Karl Knechtel Oct 09 '22 at 03:56
1 Answers
0
try this
import glob
glob.glob("path/to/folder/*.jpg")
you may change the file format to .png or any format you are using.

se7en
- 671
- 4
- 18
-
1
-
"What does this return?" Did you **try it**? Did you try [reading the documentation](https://docs.python.org/3/library/glob.html)? – Karl Knechtel Oct 09 '22 at 04:00
-
1Yes, I tried reading the documentation. Yes, I tried it. But I was just curious... – L8R Oct 09 '22 at 13:31