Using Ruby, I am able to get all the files in a directory, I use this code:

myfiles = Dir.glob("*")

To get the files in a certain path, I just include the path before the glob:

myfiles = Dir.glob("/var/www/*")

Since its a glob, I can choose an extension to filter with:

myfiles = Dir.glob("*.png")