【发布时间】:2022-10-21 20:29:01
【问题描述】:
我是一个 linux 人,并且是 windows 新手,我正在尝试创建一个小的 vbs 脚本来创建一堆文件夹。 我试图根据用户输入创建一个主文件夹,并在其中创建具有静态名称的 4 个子文件夹。我不知何故为主文件夹和子文件夹获得了两个单独的工作脚本,但我想将它们结合起来,这意味着一旦根据用户输入创建主文件夹,接下来它应该在其下创建子文件夹。
根据用户输入创建 Mainfolder.vbs 的脚本:
strfolder = InputBox("Please enter a name for your new folder:")
set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CreateFolder "C:\test\" & strfolder
创建 subfolders.vbs 文件夹的脚本:
Option Explicit
dim wshShell
set wshShell = wscript.CreateObject("WScript.Shell")
DIM fSO
DIM foldername1
DIM foldername2
DIM foldername3
DIM foldername4
foldername1=("subfolder1")
foldername2=("subfolder2")
foldername3=("subfolder3")
foldername4=("subfolder4")
dim folderpath
SET FSO=CreateObject("Scripting.FileSystemObject")
folderpath = "C:\test" & _
"\" & foldername1
wscript.echo "Creating folder: " & folderpath
FSO.CREATEFOLDER(folderpath)
folderpath = "C:\test" & _
"\" & foldername2
wscript.echo "Creating folder: " & folderpath
FSO.CREATEFOLDER(folderpath)
folderpath = "C:\test" & _
"\" & foldername3
wscript.echo "Creating folder: " & folderpath
FSO.CREATEFOLDER(folderpath)
folderpath = "C:\test" & _
"\" & foldername4
wscript.echo "Creating folder: " & folderpath
FSO.CREATEFOLDER(folderpath)
简而言之,如何根据用户输入创建主文件夹和具有静态名称的子文件夹?
想将这两者结合起来并作为一个脚本一起工作。
【问题讨论】: