ajtsystems
IS-IT--Management
Hi, I have a script which uses the date function to create a variable which is basically the name of a logfile with a time stamp - i.e logfile name = error-2010-06-19_03.log
I've written a script that looks for this logfile see below:
errorvar = "error-"
logvar = ".log"
ext1 = "_01"
ext2 = "_02"
ext3 = "_03"
ext3 = "_04"
dt=date
wscript.echo dt 'how it is displayed does not matter
yyyy=year(dt)
mm=month(dt)
dd=day(dt)
wscript.echo yyyy & vbcrlf & mm & vbcrlf & dd
mm=right("00" & mm,2)
dd=right("00" & dd,2)
'wscript.echo errorvar & yyyy & "-" & mm & "-" & dd & ext1 & logvar
datevar = errorvar & yyyy & "-" & mm & "-" & dd & ext1 & logvar
'On Error Resume Next
Set objFSO = CreateObject("Scripting.FileSystemObject")
ShowSubFolders objFSO.GetFolder("C:\scripts")
Sub ShowSubFolders(Folder)
For Each file In Folder.Files
Set objCurFile = objFSO.GetFile(file)
'look for logfile instring....
If Instr(objCurFile.Name, datevar) Then wscript.echo objcurfile.name
Next
End Sub
The problem I have is that in the logfile there is a counter which changes when the file reasches 1mb so there might be 3 or 4 logfiles but with different counter like
error-2010-06-19_03.log
error-2010-06-19_02.log
error-2010-06-19_01.log
I will need to find either teh date modified or the hightest number in of the counters.
Question would I need an array or is there a function that would do this...
any help much appreciated
I've written a script that looks for this logfile see below:
errorvar = "error-"
logvar = ".log"
ext1 = "_01"
ext2 = "_02"
ext3 = "_03"
ext3 = "_04"
dt=date
wscript.echo dt 'how it is displayed does not matter
yyyy=year(dt)
mm=month(dt)
dd=day(dt)
wscript.echo yyyy & vbcrlf & mm & vbcrlf & dd
mm=right("00" & mm,2)
dd=right("00" & dd,2)
'wscript.echo errorvar & yyyy & "-" & mm & "-" & dd & ext1 & logvar
datevar = errorvar & yyyy & "-" & mm & "-" & dd & ext1 & logvar
'On Error Resume Next
Set objFSO = CreateObject("Scripting.FileSystemObject")
ShowSubFolders objFSO.GetFolder("C:\scripts")
Sub ShowSubFolders(Folder)
For Each file In Folder.Files
Set objCurFile = objFSO.GetFile(file)
'look for logfile instring....
If Instr(objCurFile.Name, datevar) Then wscript.echo objcurfile.name
Next
End Sub
The problem I have is that in the logfile there is a counter which changes when the file reasches 1mb so there might be 3 or 4 logfiles but with different counter like
error-2010-06-19_03.log
error-2010-06-19_02.log
error-2010-06-19_01.log
I will need to find either teh date modified or the hightest number in of the counters.
Question would I need an array or is there a function that would do this...
any help much appreciated