Link to home
Start Free TrialLog in
Avatar of toros
toros

asked on

Contentspage

Can anyone tell me how I could make some kind of script that creates a page with a list of links based on the files in the same directory and their titles. I use WinNT and IIS4. So I guess it could be done both in JavaScript or ASP.

Tor Olaf
Avatar of mcix
mcix

With ASP you can use the File System Object.  I think I have some code that does that sort of thing...
Crude solution, but...

With IIs, set Directory Browsing Allowed for that directory (via management console). When a browser navigates to that directory without specifying a legal file name (and a default page does not exist) the server will return a linked list of filenames.

Presenting the <TITLE> would require some scripting.
ASKER CERTIFIED SOLUTION
Avatar of MasseyM
MasseyM

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of toros

ASKER

Thanks. It gave me some ideas about how to solve it. If somebody's interrested, a solution that works follows :

<%@ LANGUAGE="VBSCRIPT" %>

<html>
<head><title></title></head>
<body>

<%
PRIVATE sub intoFold(newfold)

 set fold = fileSYSObj.GetFolder(newfold)                  
 Set foldCol2 = fold.Files                              
 
For Each Y in foldCol2                                    
      Response.Write "<A HREF='" & newfold & "\" & Y.Name & "'>"            
      ReadAllTextFile(newfold & "\" & Y.Name)
Next                                                      
      
end sub

Function ReadAllTextFile(FilePath)
  Const ForReading = 1, ForWriting = 2
  Dim fso, f
  Set fso = CreateObject("Scripting.FileSystemObject")
  Set f = fso.OpenTextFile(FilePath, ForReading)
  ReadAllTextFile =  f.ReadAll
  WriteTitle(ReadAllTextFile)
End Function

Function WriteTitle(Text)
      Dim MyString,MyString2
      MyString = Split(Text, "<TITLE>", -1, 1)
      ' MyString(0) contains Trash.
      ' MyString(1) contains the next splitstring.
      MyString2 = Split(MyString(1),"</TITLE>",-1,1)
      ' MyString2(0) contains the title
      Response.Write MyString2(0) & "</A><BR>"
End Function

Set fileSYSObj = CreateObject("Scripting.FileSystemObject")       
intoFold("d:\test")                                    
%>
</body>
</html>