Creating an Index File with GIF Graphics


 

If your web server doesn't allow directory browsing, here's a quick way to create an index file.


I was creating a CDROM version of a web site when I hit a problem. The CDROM I was making had a small embedded web server, but that server didn't allow directory browsing! I didn't want the drudge work of manually creating default web pages. I wanted icons, not just a text directory listing. I wanted the script that created the index file to be a standalone solution, so that meant no separate graphic files.

The solution? I converted over 60 different icon graphic files into hex-encoded data and stored them in the script. When the script creates an index file, it uses the hex data to re-create the original graphic file. It puts the graphics wherever you want -- in the same directory you're indexing or in a common graphics folder. All the links in the index file are automatically made relative, so your page will work with both the file:// and http:// protocols. You can change the name of the generated index file (the default is "index.html") by modifying a constant in the script. You can even change what files get what icon by modifying dictionary code in the script. You can either drag a folder and drop it on the script or you can associate the script as a right-click option for folders. Or yes, you can use it from the command line.

Sound interesting? Download the script.

Here's what a generated page looks like:


Here are the icons you'll find embedded in the script:

Like everything else I create, there may be undiscovered bugs. Let me know if you find any so I can get them corrected.
 
 

Lost? Look at the site map.

Bad links? Questions? Send me mail.

Google
Yahoo
Ask Jeeves