There are several ways to do this. You can use the listdir()
built-in
from the os
module:
import os
filenames = os.listdir("directory/")
You can also use the glob
module, which can be handy since it allows pattern
matching:
import glob
filenames = glob.glob("directory/*.jpg")