Trying to create multiple folders with VBScript

给你一囗甜甜゛ 提交于 2019-12-11 16:52:19

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/3824175/trying-to-create-multiple-folders-with-vbscript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!