I am trying to create an automatically generate a table of contents page for a directory with a variable number of HTML files. I have created this:
<ul>
<%
dim fs,fo,x
set fs=Server.CreateObject("Scripting.FileSystemObject")
set fo=fs.GetFolder("c:\test\html\")
for each x in fo.files
newName=Split(x.Name, ".")
'Print the name of all files in the test folder
for each y in newName
Response.write("<li><a href='" & x.Name & "'>" & y & "</a></li>")
next
next
set fo=nothing
set fs=nothing
%>
</ul>
The problem here is that the links are generated using the file name, so I get things like “introduction” instead of “Introduction to This Topic.” The html > head > title element in each HTML document is the link text I want to use. Is there a way I can extract it from each file?
(I am open to a solution that doesn’t use ASP. I created this simply because it was what I had available to me. I’m not very familiar with ASP or its capabilities, so there might be a more efficient way to tackle this problem.)
There’s no saying that all of the files in a folder are actually used and are part of a site, or how these files relate in a sitemap structure. It’s better to approach this from a crawler on the outside than a file-system on the inside.
There are various sitemap generating services on the web that you can use. You can grab the results and edit them to suit your needs and post them as your own directory.