If you have a lot of files stored in a directory, you can scan that directory (see man for dir functions), make an array of file names and store them in database with any prefix ([url]ftp://ftp.myserver.com/downloads/[/url] or whatever you need).
As I don't know anything about your script, I can't tell you any more.