• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 805
  • Last Modified:

Get directory name into variable based on root directory FSO VBScript

Hello,

I have an VBS file I am working on which I need a hand with.  I need to a function which opens a directory and returns the name of a subdirectory within it.  Basically I have a root directory, and inside that directory are 2 things.. The first is a .MDB file, and the second is a subdirectory.  I know the name of the .MDB file each time, but the name of the subdirectory varies.  How can I get the name of the single subdirectory into a variable?  Thanks!
0
electricd7
Asked:
electricd7
  • 2
1 Solution
 
sirbountyCommented:
example:
Dim objFSO : Set objFSO = CreateObject("Scripting.FileSystemObject")
RootDir = "C:\MyFolder\"
 
Dim objFolder : Set objFolder = objFSO.GetFolder(RootDir)
 
For Each subfolder in objFolder.SubFolders
  msgbox "Subfolder is " & subfolder
Next

Open in new window

0
 
electricd7Author Commented:
Duh!  Thanks again sirbounty!
0
 
sirbountyCommented:
Glad I could help! :^)  Thanx for the grade!
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now