Create a nested folder structure with the file system object.

We needed to make some nested folder structures for a project we are running with mrs scripts and i thought i would post some code to do that.  I am sure there are many ways to do this , but this is what we did in just a few lines

 

Dim sPath , oItem, sCurrentPath,oFSO


Set oFSO = CreateObject("Scripting.FileSystemObject")

For each oItem in split("C:\Temp\Doug\Doug1\Doug2\","\")

if ( find(oItem,":") > -1 ) then 
      sCurrentPath = oItem + "\"
else
      sCurrentPath = replace(sCurrentPath + "\" + oItem,"\\","\")
End If

If oFSO.FolderExists(sCurrentPath) = False Then
      debug.Log(sCurrentPath)
      oFSO.CreateFolder(sCurrentPath)
End If


Next