Share this page 

Create unique folder nameTag(s): WSH VBScript


The folder name will be based on the current date and time.
Option Explicit

Dim objFSO, dNow, yy, mt, dd, hh, nn, ss, NewFolder
Set objFSO = CreateObject("Scripting.FileSystemObject")

dNow = Now
yy = Right(Year(dNow), 2)
mt = Right("00" & Month(dNow), 2)
dd = Right("00" & Day(dNow), 2)
hh = Right("00" & Hour(dNow), 2)
nn = Right("00" & Minute(dNow), 2)
ss = Right("00" & Second(dNow), 2)

NewFolder = "c:\" & yy & mt & dd & hh & nn & ss

'Create the folder
objFSO.CreateFolder NewFolder