I have a folder composed of files :
"1.txt"
"2.txt"
I need to compress them in a zip thanks to 7-zip via a batch file. Everything is working well with this script :
7za a my_zip.rar 1.txt 2.txt
I get a my_zip.rar containing the two files.
The problem is that I need to name the zip file with the date at the time the batch file is executed. So I tried this script :
set year=%date:~10,4%
set month=%date:~4,2%
7za a %year%_%month%.rar 1.txt 2.txt
I am getting a folder called "_2" containing a ".rar" containing my 2 files. I would like to have a "2014_12.rar" file containing my 2 files.
EDIT : Script output :
D:\Users>zip.bat
D:\Users>set year=
D:\Users>set month=2/
D:\Users>echo _2/.rar 1.txt 2.txt
_2/.rar 1.txt 2.txt
D:\Users>7za a _2/.rar 1.txt 2.txt
7-Zip (A) 9.20 Copyright (c) 1999-2010 Igor Pavlov 2010-11-18
Scanning
Updating archive _2/.rar
Compressing 1.txt
Compressing 2.txt
Everything is Ok
My zip.bat used :
set year=%date:~10,4%
set month=%date:~4,2%
echo %year%_%month%.rar 1.txt 2.txt
7za a %year%_%month%.rar 1.txt 2.txt
Thanks in advance for your help