GeneratePath (VBScript function to create folders recursively)

Send Us a Sign! (Contact Us!)
Word PDF Epub Text
XML OpenOffice XPS MHT

This function will generate / create a single folder (if the parent path already exist) or a complete path+folder if the absolute path doesn't already exist.

Function GeneratePath(pFolderPath)
GeneratePath = False
If Not objFSO.FolderExists(pFolderPath) Then
If GeneratePath(objFSO.GetParentFolderName(pFolderPath)) Then
GeneratePath = True
Call objFSO.CreateFolder(pFolderPath)
End If
Else
GeneratePath = True
End If
End Function

Example

This example will create a complete path if test1....test8 will not exist....

GeneratePath("C:\test1\test2\test3\test4\test5\test6\test7\test8\test9")

SOURCE

LINK

LANGUAGE
ENGLISH

1 thought on “GeneratePath (VBScript function to create folders recursively)”

Comments are closed.