我的变量copyFolderPath
为c:\images\movies\users\joe\
我有以下代码:
If objFSO.FolderExists(copyFolderPath) = False Then
Wscript.Echo "Creating: " + copyFolderPath
objFSO.createFolder copyFolderPath
End If
问题是,如果该目录不存在,则只创建joe
目录。我需要的代码也会创建users
,movies
或images
目录,如果它们不存在的话。
我该怎么做?
答案 0 :(得分:0)
我最终使用了这个功能:
Sub subCreateFolders(strPath)
If Right(strPath, 1) <> "\" Then
strPath = strPath & "\"
End If
strNewFolder = ""
Do Until strPath = strNewFolder
strNewFolder = Left(strPath, InStr(Len(strNewFolder) + 1, strPath, "\"))
If objFSO.FolderExists(strNewFolder) = False Then
objFSO.CreateFolder(strNewFolder)
End If
Loop
End Sub