通过合并两个 VBS 代码创建多个文件夹
Posted
技术标签:
【中文标题】通过合并两个 VBS 代码创建多个文件夹【英文标题】:Create multiple folders by merging two VBS codes 【发布时间】:2020-04-20 16:55:16 【问题描述】:'I have 2 scripts but could not combine them
'create multiple folders script:
Dim objFSO, objFolder, strDirectory, i
strDirectory = "C:\Users\test\Desktop\"
Set objFSO = CreateObject("Scripting.FileSystemObject")
i = 1 ''
While i < 150
Set objFolder = objFSO.CreateFolder(strDirectory & i)
i = i+1
''WScript.Quit ''
Wend
'desktop path script
set WshShell = WScript.CreateObject("WScript.Shell")
strDesktop = WshShell.SpecialFolders("Desktop")
wscript.echo(strDesktop)
我希望代码自动找到桌面路径然后创建文件夹,请有人帮帮我吗?
【问题讨论】:
【参考方案1】:要获取桌面文件夹路径字符串并创建子目录,您可以这样做:
Set objShell = Wscript.CreateObject("Wscript.Shell")
strPath = objShell.SpecialFolders("Desktop")
Dim objFso
Set objFso = WScript.CreateObject("Scripting.FileSystemObject")
If Not objFso.FolderExists(strPath + "\NewFolder") Then
objFso.CreateFolder strPath + "\NewFolder"
【讨论】:
以上是关于通过合并两个 VBS 代码创建多个文件夹的主要内容,如果未能解决你的问题,请参考以下文章
通过合并两个配置文件来创建 System.Configuration.Configuration?
【OFFICE 365】Power Query 多工作簿合并