Reading foldername and creating array

Posted on 2007-10-18
Medium Priority
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

RobSampson earned 500 total points
ID: 20106310
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.



Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is an addendum to the following article: Acitve Directory based Outlook Signature (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_24950055.html) The script is fine, and works in normal client-server domains…
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Loops Section Overview
Suggested Courses
Course of the Month16 days, 19 hours left to enroll

864 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