It is one step of my backup script under Windows 2000. Of course it works under Windows XP.
First, I use 7z as my default compress tool. Not because of it is a free, Open Source software, but it supports more format and compress methods.
The command program is 7z.exe under the installation of 7z package.
You can download it from here.
I use it in my daily backup script. So, the file name is contain date information.
7z a %DATE:~-4%-%DATE:~4,2%-%DATE:~7,2%.7z *.sql
The output file name looks like:
2009-05-26.7z
The original file is a MySQL database exporting file. So the name is *.sql.
a means add files into 7z file.
I don’t use method switch. The default is LZMA.
I give you an example. I have a database sql file about 184MB. The compressed file made by above command is 31MB. Very tiny.
Actually it’s something like %DATE:~-4%-%DATE:~3,2%-%DATE:~0,2%.7z
Your “4,2” cuts the ‘0’ from the month and the “7,2” includes the ’01’ from the year for the day, instead of the actual day.
But a good idea nonetheless, since I was looking for a 7zip switch that could put the date in the filename, forgetting I could do that directly in the filename formatting.