So, an example...
Say you want to automate the creation of a file system hierarchy, with folders that don't currently exist, and branch pretty deeply. Using the following function, you can pass a long path and the File System Object will create each layer:
makeDirectory "c:\diablopup\testing\a"
- '''''''''''''''''''''''''''''''''''''''''''''''''''
- ' This method is responsible for creating a directory
- ' The directory can be several layers deep, and if the
- ' parent directories don't exist, it creates them.
- ' If the directory already exists, it is left alone
- ''''''''''''''''''''''''''''''''''''''''''''''''
- sub makeDirectory (newPath)
- Dim myArray,length,count,path,outputFileObject
- Set outputfileObject = CreateObject("Scripting.FileSystemObject")
- if outputfileObject.FolderExists(newPath) then
- wscript.echo "Dir: "&newPath&" already exists <-- makeDirectory() "
- exit sub
- end if
- path = ""
- count = 0
- myArray = split(newPath, "\")
- length = ubound(myArray)
- while count <= length
- path = path + myArray(count) + "\"
- count = count + 1
- if not outputfileObject.FolderExists(path) then
- end if
- outputfileObject.CreateFolder(path)
- wend
- wscript.echo "Created Dir: "&newPath&" <-- makeDirectory() "

