How to create a vbscript to create a folder with the date and time
Set objFSO = CreateObject("Scripting.FileSystemObject")
'Get current time in to a variable
dtmValue = Now()
'use date /time part functions to create the folder names as required
'Assuming that you are creating these folders in C:\
strDate = "C:\" & Month(dtmValue) & "_" & Day(dtmValue) & "_" & Year(dtmValue)
strTime = strDate & "\" & Hour(dtmValue) & "-" & Minute(dtmValue) & "-" & Second(dtmValue)
'Wscript.Echo strDate
'Wscript.Echo strTime
'Create the folders using objFSO
'First check if folders exists and create only they dont exist
if objFSO.FolderExists(strDate) Then
if not objFSO.FolderExists(strTime) Then
objFSO.CreateFolder(strTime)
End If
Else
'Create Top level folder first
objFSO.CreateFolder(strDate)
'Create subfolder
objFSO.CreateFolder(strTime)
End If
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.