I'm trying compress folders using batch script with 7zip
But SET function inside if statement is not working ;(
Folders structure:
2000/
01/
02/
03/
04/
05/
06/
07/
08/
09/
10/
11/
12/
2001/
01/
02/
03/
04/
05/
06/
07/
...
Here is my code:
@ECHO OFF
setlocal
echo %date%
set logMonth=%date:~4,2%
set logDay=%date:~7,2%
set logYear=%date:~10,4%
set path="C:\Program Files\7-Zip\";%path%
if %logMonth% EQU 01 (
set logMonth=12
set /a logYear=%logYear%-1
7z a -tzip c:\%logYear%%logMonth%.zip C:\files\v2-output\%logYear%\%logMonth%
) ELSE (
rem 1 saraas busad sar bol tuhain onii umnuh sariin folderiig ziplene
set /a logMonth=%logMonth%-1
7z a -tzip c:\%logYear%%logMonth%.zip C:\files\v2-output\%logYear%\%logMonth%
)
endlocal
If current month equivalent 01 compress folder last month of previous year, else compress previous month of current year. Help guys!