''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Script : Verzeichnis in einer
HTML-Datei ausgeben '
' File : 04_02_Dir2HTML.vbs '
' Date : 2007-02-08 - Last modified: 2007-02-08 '
' '
' Michael Puff - [
url]http://www.michael-puff.de[/
url] '
' '
' Durch ein File-Container Attribut iterieren '
' Erzeugen einer Textdatei '
' Aufruf des IE-
COM Objektes '
' Funktionsaufrufe '
' Dynamische Arrays '
' '
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Constants
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim file_array()
Dim FOLDER As String
Dim HTMLFILE As String
Dim STYLESHEET As String
Dim OUTFOLDER As String
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Subs
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Page header
Private Sub HTMLHeader(ts)
ts.WriteLine "<
html>"
ts.WriteLine "<head><link rel='stylesheet' type='text/css' href='" & STYLESHEET & "'></head>"
ts.WriteLine "<body>"
End Sub
' Page footer
Private Sub HTMLFooter(ts)
ts.WriteLine "</body>"
ts.WriteLine "</
html>"
End Sub
' BubbleSort
Function bubblesort(arrSortieren)
For i = 0 To UBound(arrSortieren)
For j = i + 1 To UBound(arrSortieren)
If arrSortieren(i) > arrSortieren(j) Then
arrTemp = arrSortieren(i)
arrSortieren(i) = arrSortieren(j)
arrSortieren(j) = arrTemp
End If
Next
Next
bubblesort = arrSortieren
End Function
Private Sub Command1_Click()
Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.CreateTextFile(OUTFOLDER & "\" & HTMLFILE)
Call HTMLHeader(ts)
Set fo = fso.GetFolder(FOLDER)
Title = "Index of " & fo.Path
ts.WriteLine "<h2>" & Title & "</h2>
"
ts.WriteLine "<table class='dir'>"
ts.WriteLine "<th class='date'>Last modified</th><th class='size'>Size</th><th class='name'>file name</th>"
Set Files = fo.Files
i = 0
ReDim file_array(Files.Count)
For Each file In Files
file_array(i) = file
i = i + 1
Next
For i = 0 To UBound(file_array)
Set Files = file_array(i)
Filedate = file.DateLastModified
Filesize = file.Size
FileName = file.Name
ts.WriteLine "<tr>"
ts.WriteLine "<td class='date'>" & Filedate & "</td>"
ts.WriteLine "<td class='size'>" & Filesize & "</td>"
ts.WriteLine "<td class='name'>[
url='" & fo.Path & "/" & FileName & "']" & FileName & "[/
url]</td>"
ts.WriteLine "</tr>"
Next
ts.WriteLine "<tr><td class='date'>File(s): " & fo.Files.Count & "</td></tr>"
ts.WriteLine "</table>"
HTMLFooter (ts)
ts.Close
'Set ie = CreateObject("InternetExplorer.Application.1")
ie.Visible = True
ie.Navigate (OUTFOLDER & HTMLFILE)
End Sub
Private Sub Form_Load()
FOLDER = "D:\Test"
HTMLFILE = "index.html"
STYLESHEET = "D:\Test\stylesheet.css"
OUTFOLDER = "D:\Test"
End Sub