rem Create Archive folder if it does not exist
if exist c:\archive goto Label1
echo creating archive
md c:\archive
rem Create rdisks folder if it doesn't exist
:Label1
if exist c:\archive\evntlogs to Label2
md c:\archive\evntlogs
rem Parse out the current date to a system variable
:Label2
for /f "tokens= 1,2,3,4 delims=/ " %%I in ('date /t') do Call :MakeString
%%J %%K %%L
rem Make new folder based on date in archive folder
md c:\archive\evntlogs\%DateString%
rem Backup the event logs
dumpel -d 1 -t -l system -f c:\archive\evntlogs\%DateString%\system.bak
dumpel -d 1 -t -l application -f
c:\archive\evntlogs\%DateString%\application.bak
dumpel -d 1 -t -l security -f
c:\archive\evntlogs\%DateString%\security.bak
goto :Cleanup
:Cleanup
rem CLEANUP..dump dir of c:\archive\evntlogs to a text file and delete old
rdisk
set T=0
dir c:\archive\evntlogs /b /o:-n > c:\scripts\edir.txt
for /F %%I in (c:\scripts\edir.txt) do Call :Killold %%I
goto END1
rem Function that set the environment variable DateString
:MakeString
Set DateString=%1%2%3
goto :EOF
:Killold - this subroutine kills logs older then 30 days
set /a T = 1+%T%
if %T% LEQ 30 goto :Killold_exit
rd /S /Q c:\archive\evntlogs\%1
:Killold_exit
goto :EOF
:END1
goto :EOF