I'm looking for a script that will scan the directory that the script is sitting in for .shtml files.
I need the script to read the title tag for each file and return the results to an html page with links to the files.
I would also like to have the results listed alphabetically in a table with at least 3 columns.
Thank you for any help I might receive :)
<%
Sub Main()
sPP = Server.MapPath(".") 'Physical Path
sUP = Request.QueryString("UP") 'URL Path
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(sPP)
Set fc = f.Files
Set ff = f.SubFolders
'--- This lists the sub folders
For Each f1 in ff
Response.Write "<a href=" & sUP & f1.name & ">" & sUP & f1.name & "</a> <br>"
Response.Write sUP & f1.name & "<br>"
Next
'--- This lists the files in the current folder
For Each f1 in fc
fname_split = split(f1.name,".")
if (fname_split(0) <> "dir") then
Response.Write sUP & f1.name & "," & fname_split(0) & "<br>"
end if
Next
Set ff = nothing
Set fso = nothing
Set f = nothing
Set fc = nothing
End Sub
Main()
%>
Yep, File::Find is good for recursive directory searches, but you could also look at the simpler opendir(), readdir and closedir() functions too.
As to parsing out the title, you could either go with the HTML::Parse module (this might be a bit of overkill to be honest), or something like this:
open(FP,"filename.shtml");
while ($foo=<FP>) {
$filecontents.=$foo;
}
close(FP);
$content=~s/\rĶ\n//g;
$content=~@<title>.*?</title>@i;
$title=$1;
Do that for every file that your directory search found, put the $title values into an array, sort, and output in the format you want...