Submitted By: Seán Rooney

Creates archive folders for script output: 2006/January/results01.txt etc. The script creates new folders for the month and year as needed. Nice for housekeeping tasks use it as a wrapper for your daily/scheduled scripts.

Visual Basic
Edit|Remove
Set fs = CreateObject("Scripting.FileSystemObject")
' Define FileSystem Objects

'Dim fso, outputfile
'Set fso = CreateObject("Scripting.FileSystemObject")
'Set outputfile = fso.CreateTextFile("c:\ipconfig.txt", True)


'============================================================================================'
'= Here we define some variables for naming the log files and creating a folder hierarchy   ='
'= based on year, month, day. No manual intervention required to keep the structure.        ='
'============================================================================================'
'Month of year for storage
MON = MonthName(Month(Date))
YR = Year(Date)
DY = Day(Date)
If Len(DY) = 1 Then DY = "0" & DY

dayname = WeekDayName(WeekDay(Date()), True)

PATH = "\\servername\srvreports"
 
YRPATH = PATH & "\" & YR
MONPATH = YRPATH & "\" & MON

If Not (fs.folderexists(PATH)) Then
	Set foldr = fs.createFolder(PATH)
End If

If Not (fs.folderexists(YRPATH)) Then
	Set foldr = fs.createFolder(YRPATH)
End If

If Not (fs.folderexists(MONPATH)) Then
	Set foldr = fs.createFolder(MONPATH)
End If

resultsfile = MONPATH & "\" & dayname & DY & ".html"