AKAI TSUKI

System development or Technical something

でフォルダ作成

Const LOG_FOLDER_PATH = "C:\"

Dim dtNow, dateStr
dtNow = Date()

Set objRegExp = new RegExp
objRegExp.Pattern = "\/"
objRegExp.Global = True
dateStr = objRegExp.Replace(dtNow,"")

Dim createFolderPath
createFolderPath = LOG_FOLDER_PATH & dateStr

Dim objFS
Set objFS = WScript.CreateObject("Scripting.FileSystemObject")

if objFS.FolderExists(createFolderPath) = 0 then 
  objFS.CreateFolder(createFolderPath)
  Set objTFile = objFS.CreateTextFile(createFolderPath & "\\test.txt")
  objTFile.Close
  
  Else
  WScript.Echo "フォルダがすでに存在します。"
  
end if

WScript.Echo "script end"