Hi Goodness,
what you need to do is best achieved using a server-side language such as PHP or ASP.
Using the file.directory functions (for PHP) just loop through each file and create your coresponding HTML code on-the-fly.
The example given in opendir documentation seems to be exactly what you want - with a small modification. If you dont know PHP - or have no access to it - not really much good
Certainly not easy in JS although possible if you can list files), but definitely easier in PHP.
The good thing about this of course is that if your directory changes, most likely as you may be dynamically adding or deleting files, you just re-process your directory listing.
Hope that helps
Alex