简体   繁体   English

尝试使用VBScript创建多个文件夹

[英]Trying to create multiple folders with VBScript

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. 我需要创建一组空文件夹,从10开始,到180。这是我要使用的脚本,但是它只创建10,而没有其他内容。

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. 我是VBScript的新手,所以问题可能很明显,但我只是看不到。 I also tried using a For loop, but that didn't seem to work at all. 我也尝试过使用For循环,但这似乎根本不起作用。

Thanks in advance to anyone who reads this. 在此先感谢阅读本文的任何人。

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. 使用此脚本,我设法创建了180个文件夹。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM