views:

13

answers:

2

I need to create A set of empty folders, starting at 10, going to 180. This is the script I'm trying to use, but it just creates 10, and nothing else.

Option Explicit
Dim objFSO, objFolder, strDirectory, i
strDirectory = "\path\to\main\folder"

Set objFSO = CreateObject("Scripting.FileSystemObject")
i = 180
While i < 180
    Set objFolder = objFSO.CreateFolder(strDirectory & i)
    i = i+1
    WScript.Quit
Wend

I'm pretty new to VBScript, so maybe the problem is obvious, but I just don't see it. I also tried using a For loop, but that didn't seem to work at all.

Thanks in advance to anyone who reads this.

A: 

You should probably figure out how to make a for loop work, but perhaps you should initilize i to 10 in your snippet, and why is the WScript.Quit inside your while loop?

JackN
A: 

I have modified your script as follows:

Option Explicit 
Dim objFSO, objFolder, strDirectory, i 
strDirectory = "C:\Temp\Test\folder" 

Set objFSO = CreateObject("Scripting.FileSystemObject") 
i = 10  '' <===== CHANGED!
While i < 180 
    Set objFolder = objFSO.CreateFolder(strDirectory & i) 
    i = i+1 
    ''WScript.Quit '' <===== COMMENTED OUT!
Wend 

With this script, I managed to create 180 folders.

fmunkert
Man oh man. It seems so obvious all of a sudden. Thanks so much.
Brandon