Export Directory Structue To File

I'm looking to get a script or find an application (free) that can successfully export a large directory structure to a file (any format - text, image, HTML, whatever) in a readable form.  I've used the Windows "tree" command however from what I've been able to figure out this only works well if the entire directory structure can be captured in the command console buffer (most of the ones I'm dealing with can't).

I know that you can do a "tree /a > file.txt" however the ASCII output gets extremely hard to read when it spans numerous pages.  The unicode output of the standard "tree" command looks fine for what I need however it looks like it's not possible to redirect the output, in unicode, to a text file even if you create the file first and save it as unicode.

If someone could get me a script, find a free (or cheap) application, or has any other way to do this it would be a huge help.

The optimal solution would be an application or script that exports the directory structure to an HTML (or other portable format) file where the folders can be expanded and collapsed like in Windows explorer.  
LVL 8
JjcampNRAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ron MalmsteadInformation Services ManagerCommented:
0
FER_GCommented:
see if some of this apps. helps you...
http://www.sharewareconnection.com/dirprinter.htm
http://www.programurl.com/software-dirprinter-downloadnow.html

FerG
Saludos
--
Ing. Fernando D. Giletta
MP: 4035 CIEC
San Fco. Cba. Arg.
0
JjcampNRAuthor Commented:
This looks pretty good, however it's a bit more complicated to get configured than I was looking for and it doesn't look like you can easily save the tree to send elsewhere (I may be wrong).  Can you provide any assistance with where to start looking at configuring the application to read from a specific directory on a server, produce the tree of all folders in that directory (I'm not concerned with files), and then how to save it so I can send the file to users without them having to re-run the scripts?

Dirprint installed and on the first run told me my evaluation period had ended.  I was unable to change anything but tried to view the directory structure of C:\ at which point it completely locked up.  I'll download again and see if I can get it to work, but so far not so much luck.
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

JjcampNRAuthor Commented:
I'm also not seeing an easy way for Treeview to produce the trees.  From what it looks like I'd need to build the trees manually - is there a way to point it at a directory and have it construct the tree?
0
PaulHewsCommented:
This exports a directory structure to an XML file, which can be displayed in a browser.  Requires a reference to Microsoft XML 2.6 or better and Microsoft Scripting Runtime.  
Option Explicit
 
Private Sub Command1_Click()
    GetFoldersRecurse "C:\temp\", "C:\temp\test.xml"
End Sub
 
Public Function GetFoldersRecurse(strPath As String, strFilename As String)
    
    Dim oFSO As FileSystemObject
    Dim xmlDoc As DOMDocument
    Dim node As IXMLDOMNode
    
    Set xmlDoc = New DOMDocument
    Set node = xmlDoc.createElement("folder")
    node.Text = GetFolderName(strPath)
    xmlDoc.appendChild node
    
    Set oFSO = New FileSystemObject
    
    Call sGetFolders(strPath, xmlDoc.documentElement, xmlDoc, oFSO)
 
    xmlDoc.save strFilename
End Function
 
Private Sub sGetFolders(ByVal strPath As String, ByRef node As IXMLDOMNode, xmlDoc As DOMDocument, ByRef oFSO As FileSystemObject)
    Dim oFolder As Folder
    
    For Each oFolder In oFSO.GetFolder(strPath).SubFolders
        Dim child As IXMLDOMNode
        Set child = xmlDoc.createElement("folder")
        child.Text = GetFolderName(oFolder.Path)
        node.appendChild child
        Call sGetFolders(oFolder.Path, child, xmlDoc, oFSO)
    Next
End Sub
 
Private Function GetFolderName(strPath As String) As String
    If Right$(strPath, 1) = "\" Then strPath = Left$(strPath, Len(strPath) - 1)
    GetFolderName = Mid$(strPath, InStrRev(strPath, "\") + 1)
End Function

Open in new window

0
JjcampNRAuthor Commented:
Sorry, VB really isn't my thing....I'm getting a syntax error on line 7 character 43 (says expected ')') and I'm not seeing where the problem is.  I do have MSXML installed as well as wscript/cscript support.  Not sure if I'd need a specific Windows Scripting Runtime package or not.  Any help is greatly appreciated!
0
PaulHewsCommented:
Ah, script.. No this is VB6...  Here is VBScript instead
GetFoldersRecurse "C:\temp\", "C:\temp\test.xml"
 
Public Function GetFoldersRecurse(strPath, strFilename)
    
    Dim oFSO 
    Dim xmlDoc
    Dim node
    
    Set xmlDoc = CreateObject("MSXML.DomDocument")
    Set node = xmlDoc.createElement("folder")
    node.Text = GetFolderName(strPath)
    xmlDoc.appendChild node
    
    Set oFSO = CreateObject("Scripting.FileSystemObject")
    
    Call sGetFolders(strPath, xmlDoc.documentElement, xmlDoc, oFSO)
 
    xmlDoc.save strFilename
End Function
 
Private Sub sGetFolders(strPath, node, xmlDoc, oFSO)
    Dim oFolder
    
    For Each oFolder In oFSO.GetFolder(strPath).SubFolders
        Dim child
        Set child = xmlDoc.createElement("folder")
        child.Text = GetFolderName(oFolder.Path)
        node.appendChild child
        Call sGetFolders(oFolder.Path, child, xmlDoc, oFSO)
    Next
End Sub
 
Private Function GetFolderName(strPath) 
    If Right(strPath, 1) = "\" Then strPath = Left(strPath, Len(strPath) - 1)
    GetFolderName = Mid(strPath, InStrRev(strPath, "\") + 1)
End Function

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
JjcampNRAuthor Commented:
This is SO close to what I need.  Is there any way to hide the <folder></folder> tags and just put the + or - signs next to the name of the folder?  I know if I send the XML off to a user they'll be overly confused about the tags, but this is doing exactly what I need.
0
PaulHewsCommented:
>next to the name of the folder?

XML tags cannot have spaces in the tagname, so we'd have to replace them with underscore, which could be problematic if there is a folder with the same name except for the underscore.... You could replace the space with * or other character that is not allowable in folder or filename....
0
JjcampNRAuthor Commented:
Hum, OK.  I think this will give me what I need and I'll play around with the script a bit.  Thanks so much for the quick responses, this will save me a lot of tedious work in the next few weeks!
0
JjcampNRAuthor Commented:
Thanks for the help, it's greaty appreciated!
0
PaulHewsCommented:
Okay, you're welcome.  Good luck with it.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Server 2003

From novice to tech pro — start learning today.