Reading foldername and creating array

Posted on 2007-10-18
Last Modified: 2008-09-10

Iam looking for a vbscript that will read folder names within a directory and store them in an array.
e.g. for the folders shown below i want to be able to read the subfolder names and store these in an array.


THank you

Question by:sydpolo
    1 Comment
    LVL 65

    Accepted Solution

    Try this:

    strSourceFolder = "C:\Temp"
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    strArrayString = ""
    For Each objSubFolder In objFSO.GetFolder(strSourceFolder).SubFolders
       If strArrayString = "" Then
          strArrayString = objSubFolder.Name
          strArrayString = strArrayString & ";" & objSubFolder.Name
       End If
    arrFolderArray = Split(strArrayString, ";")

    and then you will have your array of folder names in arrFolderArray.



    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Recently I finished a vbscript that I thought I'd share.  It uses a text file with a list of server names to loop through and get various status reports, then writes them all into an Excel file.  Originally it was put together for our Altiris server…
    When it comes to writing scripts for a Client/Server computing environment it is essential to consider some way of enabling the authentication functionality within a script. This sort of consideration mainly comes into the picture when we are dealin…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now