Solved

Contentspage

Posted on 1998-10-02
4
142 Views
Last Modified: 2013-12-25
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
0
Comment
Question by:toros
4 Comments
 
LVL 4

Expert Comment

by:mcix
ID: 1855408
With ASP you can use the File System Object.  I think I have some code that does that sort of thing...
0
 
LVL 4

Expert Comment

by:raoool
ID: 1855409
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.
0
 
LVL 10

Accepted Solution

by:
MasseyM earned 100 total points
ID: 1855410
Here is a program that I wrote in ASP to list all the graphics in a directory and then send them to a script so I could see how they look as backgrounds:

GO2.ASP
--------------------------------------------------------
<html>
<head><title></title></head>
<body>

<STYLE>
TH      {
      color:Black;
      background:Silver;
      }

</STYLE>

<% SG = Request.QueryString("SG") %>

<%

Set fs = CreateObject("Scripting.FileSystemObject")       'Create the FileSystemObject
If Request.QueryString("F") = "" then
      Response.Write "<FORM METHOD=GET>"
      Response.Write "Which Directory should I start in?&nbsp;<INPUT NAME=""F"" VALUE="":\"">"
      Response.Write "<INPUT TYPE=SUBMIT VALUE=""Browse Directory""><BR>"
      Response.Write "Show Graphics as Thumbnails? <INPUT TYPE=RADIO NAME=""SG"" VALUE=1> Yes | <INPUT TYPE=RADIO NAME=""SG"" VALUE=0> No"
      Response.Write "</FORM>"
Else
      Set fold = fs.GetFolder(Request.QueryString("F"))
Response.Write ("<TABLE WIDTH='100%'>")
Response.Write ("<TR><TD>")

 Response.Write ("      <TABLE BORDER WIDTH='100%'>")
 Response.Write ("            <TH ALIGN =LEFT><A STYLE=""text-align:left;"" HREF=/>Back</A></TH>")
 Response.Write ("                  <TABLE BORDER WIDTH='100%'>")
 Response.Write ("                        <TH ALIGN = CENTER>" & fold.Path & "</TH>")
 Response.Write ("                  </TABLE>")
 Response.Write ("      </TABLE>")
 Response.Write ("</TD></TR>")

response.Write "<TABLE WIDTH='100%'><TR><TD VALIGn=TOP>"
Response.Write "<TABLE WIDTH='100%'>"
 Set foldCol = fold.SubFolders                              'Create a SubFolders collection
 For Each Y in foldCol                                    'Iterate through it
  Response.Write "<TR>"                              
  Response.Write "<TD><IMG SRC='/GRAPHICS/Folder.Gif'><A HREF=go2.asp?F=" & Y.Path
  If SG = "1" then Response.Write "&SG=1"
  Response.Write ">" &Y.Name & "</A>"
  Response.Write "</TD>"
  Response.Write "</TR>"
 Next
  Response.Write "</TABLE>"

Response.Write "</TD><TD>"

response.Write "<TABLE WIDTH='100%'>"
 Set foldCol2 = fold.Files                              'Create a Files collection
 For Each Y in foldCol2
 Cur = Cur + 1                                    'Iterate through it
  If Cur >= 6  then Response.Write "<tr>"      
  Response.Write "<td WIDTH='20%'>"
If Right(Y.Path,3) = "gif" or Right(Y.Path,3) = "jpg" then
  If SG = "1" then
      Response.Write "<IMG WIDTH =50 HEIGHT=50  SRC=" & Y.Path &" ><BR>"
  End If
  Response.Write "<A HREF=ViewasBG.asp?G=" & Y.Path
  If SG = "1" then Response.Write "&SG=1"
  Response.Write ">" &Y.Name & "</A>"            'Print the files name
End If
  Response.Write "</td>"
  If Cur >= 5 then
      Response.Write "</tr>"
      Cur = 0
  End If
 Next                                                      
 Response.Write "</table>"
 For Each Y in foldCol                                    'Now lets iterate through the folder collection again
 Next
Response.Write "</TABLE>"
Response.Write "</TD></TR></TABLE>"
End If
%>


ViewasBG.ASP
----------------------------------------------------------
<% Graphic = Request.QueryString("G") %>
<% UT = Request.QueryString("UT") %>
<% UT = 1 %>
<% If UT = "1" then %>
<% ML=Request.QueryString("ML") %>
<!-- #Include Virtual="/Sample.Asp"-->
<% End If %>
<%
Set fs = CreateObject("Scripting.FileSystemObject")
%>

</BODY>


SAMPLE.ASP
----------------------------------------------------
anything you want.. I use all the colors so I can see how they look against the background..

0
 

Author Comment

by:toros
ID: 1855411
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>
0

Featured Post

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Learn by example how to specify CSS selectors for Selenium WebDriver test automation software.
"In order to have an organized way for empathy mapping, we rely on a psychological model and trying to model it in a simple way, so we will split the board to three section for each persona and a scenario and try to see what those personas would Do,…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question