Better yet, in this context, would be to use the glob function. you'll want to prefix the glob with the directory, so your glob would likely be something like images/*.jpg.