'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Script : Verzeichnis in einer HTML-Datei ausgeben ' ' File : 04_02_Dir2HTML.vbs ' ' Date : 2007-02-08 - Last modified: 2007-02-11 ' ' ' ' Michael Puff - http://www.michael-puff.de ' ' ' ' Durch ein File-Container Attribut iterieren ' ' Erzeugen einer Textdatei ' ' Aufruf des IE-COM Objektes ' ' Funktionsaufrufe ' ' Dynamische Arrays ' ' ' '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Option Explicit ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Constants ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' dim Folder FOLDER = "D:\Homepage\michael-puff.de\Berufsschule\Anwendungsentwicklung - Johlen\VBScripte" dim HTMLFILE HTMLFILE = "index.html" dim STYLESHEET STYLESHEET = "D:\Homepage\michael-puff.de\Berufsschule\Anwendungsentwicklung - Johlen\VBScripte\stylesheet.css" dim OUTFOLDER OUTFOLDER = "D:\Homepage\michael-puff.de\Berufsschule\Anwendungsentwicklung - Johlen\VBScripte" ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' dim fso dim fo dim files dim file dim ts dim title dim filearray() dim sortedarray dim i dim s dim Filedate, Filesize, Filename dim ie ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Subs ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Page header private sub HTMLHeader(ts) ts.WriteLine "" ts.WriteLine "
" ts.WriteLine "" end sub ' Page footer private sub HTMLFooter(ts) ts.WriteLine "" ts.WriteLine "" end sub ' BubbleSort function BubbleSort(arrsort) dim i, j, k dim s1, s2, s dim filesize1, filesize2 dim temp for i = 0 to ubound(arrsort) - 1 for j = i + 1 to ubound(arrsort) - 1 s1 = Split(arrsort(i), ",", -1, vbTextCompare) filesize1 = CLng(s1(2)) s2 = Split(arrsort(j), ",", -1, vbTextCompare) filesize2 = CLng(s2(2)) if filesize1 < filesize2 then temp = arrsort(i) arrsort(i) = arrsort(j) arrsort(j) = temp end if next next bubblesort = arrsort end function ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Set fso = CreateObject("Scripting.FileSystemObject") Set ts = fso.CreateTextFile(OUTFOLDER & HTMLFILE) HTMLHeader(ts) Set fo = fso.GetFolder(FOLDER) title = "Index of " & fo.Path ts.WriteLine "| Last modified | Size | file name | " Set files = fo.Files ReDim filearray(files.Count) For Each file In files filearray(i) = file & "," & file.DateLastModified & "," & file.Size & "," & file.Name i = i + 1 Next ReDim sortedarray(files.Count) sortedarray = BubbleSort(filearray) For i = 0 To ubound(sortedarray) - 1 s = Split(sortedarray(i), ",", -1, vbTextCompare) Filedate = s(1) Filesize = s(2) Filename = s(3) ts.WriteLine "
|---|---|---|
| " & Filedate & " | " ts.WriteLine "" & Filesize & " | " ts.WriteLine "" & Filename & " | " ts.WriteLine "
| File(s): " & fo.files.Count & " |