From: Jason on
Hello

Is there a easy way to create the folder path c:\folder1\folder2\folder3 ?


From: Steve on
Jason wrote:
>
> Is there a easy way to create the folder path
> c:\folder1\folder2\folder3 ?

Const FULL_PATH = "c:\folder1\folder2\folder3"
Set fso = CreateObject("Scripting.FileSystemObject")

BuildPath FULL_PATH

Sub BuildPath(ByVal Path)
If Not fso.FolderExists(Path) Then
BuildPath fso.GetParentFolderName(Path)
fso.CreateFolder Path
End If
End Sub

--
Steve

Courage is resistance to fear, mastery of fear-not absence of fear.
-Mark Twain


From: LikeToCode on
Or simply:

Set objFSO = CreateObject("scripting.filesystemobject")
objFSO.CreateFolder("c:\folder1\folder2\folder3")

This uses the CreateFolder Method of FileSystemObject. More information can
be found here:
http://msdn.microsoft.com/en-us/library/6tkce7xa(VS.85).aspx

and

http://msdn.microsoft.com/en-us/library/7kby5ae3(VS.85).aspx

From: ekkehard.horner on
LikeToCode schrieb:
> Or simply:
>
> Set objFSO = CreateObject("scripting.filesystemobject")
> objFSO.CreateFolder("c:\folder1\folder2\folder3")
>
> This uses the CreateFolder Method of FileSystemObject. More information can
> be found here:
> http://msdn.microsoft.com/en-us/library/6tkce7xa(VS.85).aspx
>
> and
>
> http://msdn.microsoft.com/en-us/library/7kby5ae3(VS.85).aspx
>
For VBScript 5.6 and 5.7 .CreateFolder won't create a folder unless
its parent folder exists. I would like to know, whether newer versions
of VBScript (FSO) are more programmer friendly.

To be on the save side, you should use a recursive sub like Steve's
or shell out for mkdir.
From: LikeToCode on
On my win7 box it is the same, this shows you how often I need to create
complete folder paths. ;-)

You can still accomplish this with 2 lines of code.

Set objShell = CreateObject("Wscript.Shell")
objShell.Run "cmd /c mkdir C:\folder1\folder2\folder3"