How to create a unique subfolder (QTP, VBScript)
Parent page: Service Functions – System (QTP, VBScript)
How to create a unique subfolder
Description
A subfolder is created based on the name pattern and a date-time stamp, e.g. “AccountSearch 2009-10-14 17-18-03”. You can add extra steps and form the code as a function that returns full path of the newly created subfolder.
sName – name pattern
sFullPath – full path of the newly created subfolder
Dim date_now, dd, dt
Dim FSO
Dim sFullPath
date_now = Now
dd = Year(date_now) & "-" & AlignNumber(Month(date_now), 2, "0") & "-" & AlignNumber(Day(date_now), 2, "0")
dt = AlignNumber(Hour(date_now), 2, "0") & "-" & AlignNumber(Minute(date_now), 2, "0") & "-" & AlignNumber(Second(date_now), 2, "0")
If sName = "" Then
sSubfolder = "Data"&" " & dd & " " & dt
Else
sSubfolder = sName & " " & dd & " " & dt
End If
sFullPath = sLogPath & "\" & sSubfolder & "\"
Set FSO = CreateObject("Scripting.FileSystemObject")
FSO.CreateFolder(sFullPath)
Set FSO = Nothing


One response to "How to create a unique subfolder (QTP, VBScript)"
Thanks a lot for all your examples and the information provided in this site, these are really helpful!