Not sure whether to post it or not.
[ Last edited by slore on 2008-12-26 at 20:25 ]
'-------------vbsTree.vbs------------------------
'Description: Output the directory structure of a folder using vbs.
' By Slore @ 2008-12-26
'------------------------------------------------
Const Unit4Size = "字节KBMBGB"
Const OutFile = "OutTree.txt"
Dim theApp, SelPath, TreePath, TreeStr
Set theApp = CreateObject("Shell.Application")
Set SelPath = theApp.BrowseForFolder(0, "Please select the path for which you need to list sub-items", 0)
If SelPath Is Nothing Then WScript.Quit
TreePath = SelPath.items.Item.Path
Set SelPathPath = Nothing
Set theApp = Nothing
Dim ShowSize
ShowSize = MsgBox("Do you need to display the size?", vbYesNo, "vbsTree By Slore") - 7
Dim objFSO
Set objFSO = CreateObject("Scripting.FileSystemObject")
TreeStr = TreePath
On Error Resume Next 'Fault-tolerant mode (ignore special folder errors)
If ShowSize Then TreeStr = TreeStr & FormatSize(objFSO.GetFolder(TreePath).Size)
TreeStr = TreeStr & vbCrLf
starttime = Timer
Tree TreePath, ""
endtime = Timer
Set objFile = objFSO.CreateTextFile(OutFile, True)
objFile.Write TreeStr
objFile.Close
Set objFile = Nothing
Set objFSO = Nothing
tottime = endtime - starttime
tottime = FormatNumber(tottime, 3, True) & " seconds"
MsgBox "Please check OutTree.txt in the current directory" & vbCrLf & "Time used: " & tottime, vbInformation, "Completed - vbsTree"
Sub Tree(Path, SFSpace)
Dim i, TempStr, FlSpace
FlSpace = SFSpace & " "
Set CrntFolder = objFSO.GetFolder(Path)
i = 0: TempStr = "├─"
For Each ConFile In CrntFolder.Files
i = i + 1
If i = CrntFolder.Files.Count And CrntFolder.SubFolders.Count = 0 Then TempStr = "└─"
TreeStr = TreeStr & FlSpace & Tempstr & ConFile.Name
If ShowSize Then TreeStr = TreeStr & FormatSize(ConFile.Size)
TreeStr = TreeStr & vbCrLf
Next
i = 0: TempStr = "├─"
SFSpace = FlSpace & "│"
For Each SubFolder In CrntFolder.SubFolders
i = i + 1
If i = CrntFolder.SubFolders.Count Then
TempStr = "└─"
SFSpace = FlSpace & " "
End If
TreeStr = TreeStr & FlSpace & TempStr & SubFolder.Name
If ShowSize Then TreeStr = TreeStr & FormatSize(SubFolder.size)
TreeStr = TreeStr & vbCrLf
Tree SubFolder, (SFSpace)
Next
End Sub
Function FormatSize(SZ)
Dim i
Do While SZ > 1024
i = i + 1
SZ = SZ \ 1024
Loop
FormatSize = " (" & SZ & Mid(Unit4Size, 1 + 2 * i, 2) & ")"
End Function
E:\IconWorkShop (11MB)
├─axlibico.dll (383KB)
├─Axstdctl.dll (18KB)
├─Context.hlp (68KB)
├─IconWorkshop.exe (5MB)
├─Main.chm (4MB)
├─MediaFiles.axd (4KB)
├─ResChs.dll (388KB)
├─sn.txt (32 bytes)
├─UnInstall.exe (74KB)
├─UnInstall.ini (109 bytes)
├─Color Swatches (54KB)
│ ├─16 Colors (extended).axco (1KB)
│ ├─16 Colors.axco (343 bytes)
│ ├─Dark Hues.axco (3KB)
│ ├─Default (large).axco (6KB)
│ ├─Default (small).axco (3KB)
│ ├─Grayscale (128 levels).axco (1KB)
│ ├─Grayscale (256 levels).axco (3KB)
│ ├─IconWorkshopSwatches (3KB)
│ ├─Medium Hues.axco (3KB)
│ ├─Pastel Hues.axco (3KB)
│ ├─Photoshop Default.axco (1KB)
│ ├─Pure Hues.axco (3KB)
│ ├─Spectrum (variable lightness).axco (6KB)
│ ├─Spectrum (variable saturation).axco (6KB)
│ ├─Spectrum.axco (3KB)
│ ├─Web Safe by VisiBone.axco (3KB)
│ ├─Web Safe.axco (2KB)
│ └─Windows XP.axco (376 bytes)
└─Color Tables (3KB)
├─IconWorkshop Standard.axct (768 bytes)
├─Macintosh.axct (768 bytes)
├─Web Safe.axct (768 bytes)
├─Windows XP.axct (768 bytes)
└─Windows.axct (768 bytes)
[ Last edited by slore on 2008-12-26 at 20:25 ]
Recent Ratings for This Post
( 5 in total)
Click for details
S smile 微笑,L love 爱,O optimism 乐观,R relax 放松,E enthusiasm 热情...Slore


