I wrote a cscript routine that's called by windows scheduler every night.
I've used this for a couple years now with good success.  Each month the
script creates a new folder for that months log files. Hope this helps.

begin code:
**********************
Dim nMonth, cMonth
Dim cYear, cYearMonth
Dim nDay, cDay, cDateString

cYear = Year(Date-1)
nMonth = Month(Date-1)
If nMonth < 10 Then
        cMonth = "0" & CStr(nMonth)
Else
        cMonth = CStr(nMonth)
End If
nDay = Day(Date-1)

If nDay < 10 Then
        cDay = "0" & CStr(nDay)
Else
        cDay = CStr(nDay)
End If

cDateString = cMonth & cDay
cYearMonth = cYear & "-" & cMonth

Dim fso, f, fc, nf
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(".")
Set fc = f.SubFolders

'See if folder exists for current month/year
If (fso.FolderExists(cYearMonth)) = False Then
        Set nf = fc.Add(cYearMonth)
End If

Dim db, Item
Set db = CreateObject("Scripting.Dictionary")
db.Add 1, "con" & cDateString & ".log"
db.Add 2, "dec" & cDateString & ".log"
db.Add 3, "vir" & cDateString & ".log"
db.Add 4, "sys" & cDateString & ".txt"
db.Add 5, "log" & cDateString & ".txt"
db.Add 6, "hi" & cDateString & ".log"
db.Add 7, "spam" & cDateString & ".log"

wscript.echo cYearMonth

For Each Item in db

        WScript.echo "Checking " & db.Item(Item)
        If Not fso.FileExists( cYearMonth & "\" & db.Item(Item) ) Then
                If fso.FileExists( "x:\IMail\Spool\" & db.Item(Item)) Then
                        wscript.echo "found"
                        wscript.echo "Moving: " & "x:\IMail\Spool\" & db.Item(Item), 
cYearMonth &
"\"
                        fso.MoveFile "x:\IMail\Spool\" & db.Item(Item), cYearMonth & 
"\"
                        WScript.echo "Moved " & db.Item(Item)
                End If
        End If
Next

Set fso = Nothing
Set f = Nothing
Set fc = Nothing
*********************************
:end of code


Gary Jorgenson, RN  President - Robin Technologies, Inc.
52 Westerville Square, Suite 159 Westerville, OH  43081
Phone: 614.895.2020 | Fax: 614.899.1580 | Cell: 614.657.8080
[EMAIL PROTECTED] | www.robintek.com


-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Gerald
Sent: Monday, January 05, 2004 10:40 PM
To: [EMAIL PROTECTED]
Subject: [IMail Forum] Moving logs


OK, this is for you batch file wizards out there. I could do this in bash
with no problem but DOS is ornery about date strings.

I move my logs (declude and IMail) off to a workstation that I use for
scanning the logs. I can't log directly to the workstation because I work
contract and frequently pack the box up and haul it to another job
temporarily.

I'm trying to create a DOS batch file that I can have run nightly that will
use MOVE to move the files to the workstation drive (I have it mounted on
the mail server with a drive letter for file moving ease).

Problem is, I can't figure out how to make it move everything EXCEPT the
current day's log files (sys####.txt and dec####.log). The DOS date command
won't give me a clean "month+day" number to work with and the unix tools
set doesn't seem to give a unix style date command to use for getting dates
in the proper format.

If I can get around the date problem I should be able to use 'move' or
'xcopy + del' to move the files I need over to the other box.

Any help appreciated.

--
Gerald V. Livingston II

Configure your Email to send TEXT ONLY -- See the following page:
http://expita.com/nomime.html



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/

Reply via email to