So, I made the following script which runs locally on the WSH and produces
an HTML file that I can upload to the same directory on my website, and it
seems to work OK. I could rename it index.htm or I could make my own index
file and provide a link to it for a clickable directory of files. Here is
the code:
============================================================
//Const ForReading = 1, ForWriting = 2, ForAppending = 8;
var objFSO, objFldr, objSFldr, objFl, objStream, sFile, sPath, sExtension;
var True = 1;
var ForWriting = 2;
// Create the FileSystemObject
objFSO = fso = new ActiveXObject("Scripting.FileSystemObject");
// The file you want the dir printed to...
sFile = ".\\FileDir.htm";
// The folder you want a dir of...
sPath = ".\\";
objStream = objFSO.OpenTextFile(sFile, ForWriting, True);
objStream.WriteLine("<html>\n");
objStream.WriteLine("<head>\n");
objStream.WriteLine("<title>Directory of Files</title>\n");
objStream.WriteLine("</head>\n");
objStream.WriteLine("<body>\n");
//objStream.WriteLine("<address>\n");
// Get the folder (line 24)
objFldr = objFSO.GetFolder(sPath);
fc = new Enumerator(objFldr.files);
var s;
for (; !fc.atEnd(); fc.moveNext()) {
s = fso.GetFileName(fc.item());
objStream.WriteLine ( '<a href="'+ s + '">' + s + '<br>');
}
objStream.WriteLine("</body>\n");
objStream.WriteLine("</html>\n");
objStream.Close();
==============================================================
I just have a few simple questions. (1) is there an equivalent to a
constant in JavaScript, (2) does objFSO need to be destroyed, and (3) is
there a way to do something like this on the server side so it will
dynamically reflect the folder contents. Otherwise if you see any errors or
problems in my code please feel free to make suggestions. I might work on
adding some formatting features to the HTML, and maybe some interactive
items in the JS, as a learning exercise.
Thanks,
Paul