遍歷當前目錄下的所有HTML檔案,並且顯示到螢幕中

dingonet發表於2010-01-22
可以使用 cscript xx.vbs>>1.htm 將顯示的文字全部寫到html檔案中[@more@]Function FilesTree(sPath)
'遍歷一個資料夾下的所有檔案與資料夾
Set oFso = CreateObject("Scripting.FileSystemObject")
Set oFolder = oFso.GetFolder(sPath)
Set oSubFolders = oFolder.SubFolders

Set oFiles = oFolder.Files
For Each oFile In oFiles
If LCase(Right(oFile.name,4))="html" Or LCase(Right(oFile.name,4))=".htm" Then
WScript.Echo "" & oFile.Name &""
End If
'oFile.Delete
Next

For Each oSubFolder In oSubFolders
WScript.Echo oSubFolder.Path
'oSubFolder.Delete
FilesTree(oSubFolder.Path)'遞迴
Next

Set oFolder = Nothing
Set oSubFolders = Nothing
Set oFso = Nothing
End Function

FilesTree(".") '遍歷

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/77544/viewspace-1030807/,如需轉載,請註明出處,否則將追究法律責任。

相關文章