This is the batch file I have created which zips the particular month logs and deletes those logs from the source folder after successful zipping. If it does not find the zip file, then it again starts to zip the logs.

Please suggest any changes to be done.

```
@echo off

set zip="C:\Program Files\7-Zip\7z.exe"
rem Findout Month, Year and Date
FOR /F "tokens=1,2,3,4 delims=/ " %%A in ('Date /t') do set year=%%D
FOR /F "tokens=1,2,3,4 delims=/ " %%A in ('Date /t') do set month=%%B
FOR /F "tokens=1,2,3,4 delims=/ " %%A in ('Date /t') do set day=%%C

rem Solve problem Year start and adding 0 in month
if %month% EQU 01 (
    set month=12
    set /a year=%year%-1
) else (
    set /a month=%month%-1
)
if %month% LSS 10 set month=0%month%

rem Set file names for last month file.
set lastmonthfiles=server.log.%year%-%month%-
rem To compress the file.
:compress
%zip% -tzip  a -y "bkp-%lastmonthfiles%.zip" %lastmonthfiles%*
ping -n 5 192.168.100.44 > nul 
if Not exist bkp-%lastmonthfiles%.zip (
    echo zipping failed
    pause
) else ( 
 DEL %lastmonthfiles%*

 ) 
pause

```