sloppycode.net
XTree
Produces a tree output of a directory structure.
Home
›
Code snippets
›
Misc
›
XTree
By Jonah R. Goldberg
XTree was designed to replace a feature that my old DR DOS used to support... XTREE. It simply crawls a directory structure and lists its contents. Change your default script engine to cscript by running "cscript //h:cscript"
'******************************* '* XTree.VBS '* Jonah R. Goldberg '* Feb 2002 '* Distribute Freely '******************************* '* XTree was designed to replace a feature that my old DR DOS used to support... XTREE '* It simply crawls a directory structure and lists its contents... '* I suggest you change your default script engine to cscript by '* running "cscript //h:cscript" '* '* Correct Usage : XTree [optional: PATH (default: Current Path)] '* Suggested Usage: Xtree > Out.txt '* (You can always redirect (pipe) a program's output to a file .) '******************************* Dim oFS Dim oFolder Dim oFile Dim oFiles Dim oSubFolders Dim oArgs Dim nArgs Dim sRootPath Set oArgs = WScript.Arguments nArgsCount = oArgs.Count Set oFS = CreateObject("Scripting.FileSystemObject") If nArgsCount < 1 Then sRootPath = "." ElseIf oFS.FolderExists(oArgs.item(0)) Then sRootPath = oArgs.item(0) Else LogMessage "Invalid Path - " & oArgs.item(0) LogMessage "Correct Usage : XTree [optional: PATH (default: Current Path)]" WScript.Quit End If '************************** 'Job Logic '************************** LogMessage "XTree Started: " & Now() Set oFolder = oFS.GetFolder(sRootPath) ProcessFolder oFolder LogMessage "Thank you For Using XTree VB Script - JG 2002." '************************** 'Object Clean Up '************************** Set oFS = Nothing Set oFile = Nothing Set oFolder = Nothing Set oSubFolders = Nothing Set oFiles = Nothing '************************** 'Supporting Functions '************************** Sub PrintFileList(oCurFold) Set oFiles = oCurFold.Files For Each oFile in oFiles LogMessage(" - " & oFile.Name) Next End Sub Sub ProcessFolder(oRootFolder) LogMessage "The following files are in " & oRootFolder.Path PrintFileList oRootFolder Set oSubFolders = oRootFolder.SubFolders For Each oSubFolder in oSubFolders ProcessFolder oSubFolder Next End Sub Sub LogMessage(sMessage) WScript.Echo sMessage End Sub
{Name}
Says:
{Date}
{Text}
› Home
› C#
› Snippets
› Articles
› Tools
› Taglines
› ASP
› Dictionary Object
› FSO
› Unix cheat sheet
› Gaming
› CSS
› Yak
› Umbraco
› About
› Contact
› Privacy
› Projects
› Search