I have a vb script that creates a folder as a sibling of the folder where the file exists. What I would like it to do is create a folder that is a child of the folder, not a sibling. I can’t figure out how to make the script create a child folder on its current path.
Anyone know how to do this?
Here’s what I have so far:
Option Explicit
Dim objFSO, objFolder, objShell, strDirectory, strCurrentDate, strMonth, strDay, strYear
dim strCurPath
strMonth = DatePart("m",Date)
strDay = DatePart("d",Date)
strYear = DatePart("yyyy",Date)
StrCurrentDate = strMonth & "-" & strDay & "-" & stryear
' Create the File System Object
Set objFSO = CreateObject("Scripting.FileSystemObject")
'Find current path
strCurPath = objFSO.GetAbsolutePathName(".")
'wscript.echo strCurPath
strDirectory = strCurPath & "_" & strCurrentDate
If objFSO.FolderExists(strDirectory) Then
Set objFolder = objFSO.GetFolder(strDirectory)
WScript.Echo strDirectory & " already created "
Else
Set objFolder = objFSO.CreateFolder(strDirectory)
'WScript.Echo "Just created " & strDirectory
End If
If err.number = vbEmpty then
Set objShell = CreateObject("WScript.Shell")
objShell.run ("Explorer" &" " & strDirectory & "\" )
Else WScript.echo "VBScript Error: " & err.number
End If
WScript.Quit