hey all
there's got to be a better way to accomplish this - I'm lousy with arrays...
as the log file for my script grows too large, I want to copy the current log to a backup file and start a fresh one. I could see myself keeping up to 10 logs. the original log is "redactc.log" and the backups are to be "redactc.log.1", "redactc.log.2", etc.
here's how I'm doing it now - Is there any way to run this sub more dynamically to allow for a greater number of backups without writing 10+ "If" statements?
see code snippet below
thanks,
rob
~~~shake and bake~~~!!!!
there's got to be a better way to accomplish this - I'm lousy with arrays...
as the log file for my script grows too large, I want to copy the current log to a backup file and start a fresh one. I could see myself keeping up to 10 logs. the original log is "redactc.log" and the backups are to be "redactc.log.1", "redactc.log.2", etc.
here's how I'm doing it now - Is there any way to run this sub more dynamically to allow for a greater number of backups without writing 10+ "If" statements?
see code snippet below
thanks,
rob
Code:
dim oFSO, strPath, strFile, oFile
Set oFSO = CreateObject("Scripting.FileSystemObject")
strPath = "c:\logs"
strFile = "\redactc.log"
Sub logsize
'get size of logfile
set oFile = oFSO.GetFile(strPath & strFile)
If ofile.size > 10000 Then
If oFSO.FileExists(strPath & strFile & ".2") Then
oFSO.DeleteFile strPath & strFile & ".2"
End IF
IF oFSO.FileExists(strPath & strFile & ".1") Then
oFSO.CopyFile strPath & strFile & ".1", strPath & strFile & ".2", True
oFSO.DeleteFile strPath & strFile & ".1"
End If
If oFSO.FileExists(strPath & strFile) Then
oFSO.CopyFile strPath & strFile, strPath & strFile & ".1", True
oFSO.DeleteFile strPath & strFile
End If
End If
Set oFile = Nothing
End Sub
~~~shake and bake~~~!!!!