Here's a modified version of Cris' script that moves files instead of
copying them (much more efficient...especially with large log files). It's
also set up to handle other log files you may have there. Change the
SpoolPath and LogPath for your system. I would schedule it a few minutes
after midnight instead of right on to avoid potential file locks that might
still be in place.
Darin.
==================================
Const OverwriteExisting = True
Const SpoolPath = "F:\IMail\spool\"
Const LogPath = "F:\IMail\spool\logarchive\"
dim currdate, curryear, oldfile
Set objFSO = CreateObject("Scripting.FileSystemObject")
currdate= ""
if month(now()-1)<10 then
currdate=currdate & "0" & month(now()-1)
else
currdate=currdate & month(now()-1)
end if
if day(now()-1)<10 then
currdate=currdate & "0" & day(now()-1)
else
currdate=currdate & day(now()-1)
end if
curryear = right(year(now()-1), 2)
MoveLog "dec", "log", ""
MoveLog "log", "txt", ""
MoveLog "spam", "log", ""
MoveLog "sys", "txt", ""
MoveLog "vir", "log", ""
MoveLog "W1", "log", curryear
MoveLog "W2", "log", curryear
Sub MoveLog(strType, strExt, strYear)
oldfile = SpoolPath & strType & strYear & currdate & "." & strExt
if objFSO.FileExists(oldfile) then
objFSO.MoveFile oldfile, LogPath
end if
End Sub
==================================
----- Original Message -----
From: "Cris Porter" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, September 08, 2004 11:21 PM
Subject: RE: [IMail Forum] Remove logs from spool directory...
Here's a little VB script that I have scheduled every night at 12:05.
There's probably a more efficient way to do it, but this works for me.
Cris
======================================================
Const OverwriteExisting = True
Set objFSO = CreateObject("Scripting.FileSystemObject")
dim currdate,oldfile,newfile
currdate= ""
if month(now()-1)<10 then currdate=currdate & "0" & month(now()-1) else
currdate=currdate & month(now()-1) end if
if day(now()-1)<10 then currdate=currdate & "0" & day(now()-1) else
currdate=currdate & day(now()-1) end if
oldfile = "D:\imail\spool\sys" & currdate & ".txt"
newfile = "E:\imaillogs\sys" & currdate & ".txt"
if objFSO.FileExists(oldfile) then
objFSO.CopyFile oldfile, newfile, OverwriteExisting
if objFSO.FileExists(newfile) then
objFSO.DeleteFile(oldfile)
end if
end if
======================================================
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Joe Wolf
Sent: Wednesday, September 08, 2004 8:18 PM
To: [EMAIL PROTECTED]
Subject: [IMail Forum] Remove logs from spool directory...
Has anyone written a batch file or utility that will remove the log files
(except the current ones of course) from the spool directory?
I keep three months of logs and it makes the spool directory confusing.
Why in the world Ipswitch decided to keep the logs in the spool directory is
beyond me!
-Joe
To Unsubscribe: http://www.ipswitch.com/support/mailing-lists.html
List Archive: http://www.mail-archive.com/imail_forum%40list.ipswitch.com/
Knowledge Base/FAQ: http://www.ipswitch.com/support/IMail/
To Unsubscribe: http://www.ipswitch.com/support/mailing-lists.html
List Archive: http://www.mail-archive.com/imail_forum%40list.ipswitch.com/
Knowledge Base/FAQ: http://www.ipswitch.com/support/IMail/
To Unsubscribe: http://www.ipswitch.com/support/mailing-lists.html
List Archive: http://www.mail-archive.com/imail_forum%40list.ipswitch.com/
Knowledge Base/FAQ: http://www.ipswitch.com/support/IMail/