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).

Asked By: Vlone

||

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.

Answered By: Horla.li
Categories: questions Tags:
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.