Just the Steps
To create a folder
|
CreateBasicFolder.vbs
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.CreateFolder("c:\fso1")
CreateMultiFolders.vbs
Option Explicit
Dim numFolders
Dim folderPath
Dim folderPrefix
Dim objFSO
Dim objFolder
Dim i
Dim objSHell
Dim myDocs
Set objSHell = CreateObject("wscript.shell")
myDocs = objSHell.SpecialFolders("mydocuments")
numFolders = 10
folderPath = myDocs & "\"
folderPrefix = "TempUser"
For i = 1 To numFolders
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.CreateFolder(folderPath & folderPreFix & i)
Next
WScript.Echo(i - 1 & " folders created")
注意:FSO创建一个文件夹时,其父目录必须已经创建好了.否则会创建失败.
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.DeleteFolder("c:\fso")
Option Explicit
Dim numFolders
Dim folderPath
Dim folderPrefix
Dim objFSO
Dim objFolder
Dim i
numFolders = 10
folderPath = "C:\"
folderPrefix = "TempUser"
For i = 1 To numFolders
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.DeleteFolder(folderPath & folderPreFix & i)
Next
WScript.Echo(i - 1 & " folders deleted")
Just the Steps
To implement For...Next
|