Click here to Skip to main content
Click here to Skip to main content

VBScript directory crawler

, 16 May 2000
Rate this:
Please Sign up or sign in to vote.
A VBScript program that can recursively walk directories and also create a true working tree (good for printouts)
  • Download source files - 1 Kb

    Sample Image - walker.jpg

    This VBScript can be used in a number of ways. At its heart, it's a simple directory tree walker. I wrote it originally as a DevStudio macro to clear out all the big leftover files in the debug and release folders. I added a bit of code to it on a whim to make it to indent the subfolders and add the various lines so that in the end it looks similar to the left hand frame of explorer. This can then be piped to a file and printed (have you ever wanted to print out a directory tree? I know I have.)

    I have commented where you could put code to do things like clear out temp files, whatever.

    Enjoy Smile | :)

  • License

    This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

    A list of licenses authors might use can be found here

    Share

    About the Author

    Ron Olson
    Web Developer
    United States United States
    No Biography provided

    Comments and Discussions

     
    GeneralDocument Properties help PinsussLen Inkster26-Jul-05 9:40 
    GeneralRe: Document Properties help PinsussMathew Gorge27-Jul-05 22:28 
    QuestionWhy it Fails? Pinmemberdougcranston27-Feb-03 5:50 
    AnswerRe: Why it Fails? PinmemberJim Smith15-Oct-04 9:09 
    GeneralRe: Why it Fails? Pinmemberdougcranston15-Oct-04 9:18 
    GeneralRe: Why it Fails? PinsussAnonymous14-Sep-05 15:32 
    GeneralShow pictures from a dir on a html-page PinmemberPBA20-Feb-02 1:43 
    GeneralSearchinf for a particular extension using VBscript PinsussGnanavel9-Oct-00 21:42 
    GeneralRe: Searchinf for a particular extension using VBscript Pinmemberdzb00724-Nov-00 9:21 
    GeneralNice! + More on scripts PinsussPhilippe Lhoste23-May-00 23:59 
    I like it, it is a nice introduction to the use of FileSystemObject with VBScript.
     
    I started playing with the code, here is a small patch:
     
    dim sf, fileColl, line
    for each sf in foldcol
    spacer = spacer + space(3) + "|"
     
    'wscript.echo spacer + "-- " + sf.name
     
    ' If you wanted to show the number of bytes, use these lines instead of above
    set fileColl = sf.Files
    line = spacer + "-- " + sf.name
    if fileColl.Count = 0 then
    wscript.echo line + " (empty)"
    else
    wscript.echo line + _
    " (uses " + cstr(FormatNumber(sf.Size, 0)) + " bytes with " + _
    cstr(FormatNumber(fileColl.Count, 0)) + " files)"
    end if
     
    I believe you should have no problem locating my patch in the source...
    Notice the use of '_' to continue a line (I don't know if it well documented), and the use of the Count property to have the number of elements in a collection (I couldn't locate this property in the MSDN doc!).
     
    Of course, you can use the fileColl to list the files or do something on them.
     
    Another trick for newbies like me:
    you can run the script by double-clicking on it, of course, but if you want to run it from a command line, you can either type:
    start vbscript_prog.vbs (with same result as double-clicking, ie. having each echo in a message box)
    wscript vbscript_prog.vbs (idem)
    or
    cscript /nologo vbscript_prog.vbs (with output on the standard output, so can be redirected to a file)
     
    Try cscript /? for more options.

    General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

    Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

    | Advertise | Privacy | Terms of Use | Mobile
    Web01 | 2.8.141220.1 | Last Updated 17 May 2000
    Article Copyright 2000 by Ron Olson
    Everything else Copyright © CodeProject, 1999-2014
    Layout: fixed | fluid