Batch File to Compress File Using Windows

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Batch File to Compress File Using Windows

#16 Post by foxidrive » 05 Nov 2012 09:55

accesshawaii wrote:
The name of the zip will need to have the date that it was backed up and the abbreviation of the previous month. So, if I did a back-up today, it would look something like below.

20121105_Oct_Data.7z



Something like this will work for you: (untested)

Code: Select all

@echo off
if  %date:~4,2%==01 set m=Dec
if  %date:~4,2%==02 set m=Jan
if  %date:~4,2%==03 set m=Feb
if  %date:~4,2%==04 set m=Mar
if  %date:~4,2%==05 set m=Apr
if  %date:~4,2%==06 set m=May
if  %date:~4,2%==07 set m=Jun
if  %date:~4,2%==08 set m=Jul
if  %date:~4,2%==09 set m=Aug
if  %date:~4,2%==10 set m=Sep
if  %date:~4,2%==11 set m=Oct
if  %date:~4,2%==12 set m=Nov

"c:\Program Files\7-Zip\7z.exe"  a -t7z -r "c:\%date:~10,4%%date:~4,2%%date:~7,2%_%m%_MyBackup.7z" "c:\MyStuff\*.*"

accesshawaii
Posts: 12
Joined: 01 Nov 2012 09:19

Re: Batch File to Compress File Using Windows

#17 Post by accesshawaii » 05 Nov 2012 11:16

That worked...Perfect. Thanks for all the assistance, I really appreciate it.

miskox
Posts: 630
Joined: 28 Jun 2010 03:46

Re: Batch File to Compress File Using Windows

#18 Post by miskox » 06 Nov 2012 01:24

foxidrive wrote:7-zip can handle more files in a ZIP than ZIP can.

7-zip also has the capability to make ZIP archives.

7-zip has superior compression compared to ZIP


Ed wrote:7-Zip 4.57 Console ( Igor Pavlov ) can unpack .ISO images


Yes, of course.
But... original author wanted to implement Windows' integrated compress function which I assume is according to zip specification and not any other. I personally prefer zip instead of any other software (rar, arj...) because it is so common that usually no other software is required.

Saso

accesshawaii
Posts: 12
Joined: 01 Nov 2012 09:19

Re: Batch File to Compress File Using Windows

#19 Post by accesshawaii » 06 Nov 2012 12:18

I understand that compression programs like 7-Zip, WinZip, etc. compress files much better than the built in windows compression. For what I'm doing though, windows compression would have worked fine. My main reason for wanting to go with that is because all users have that installed on their machines. The batch file itself is working in conjunction with an Access database, which will execute the batch file and then carry-out a series of routines.

It's working with 7-Zip though, so I'm happy with it as is because I do not anticipate the users needing to run this on a regular basis.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Batch File to Compress File Using Windows

#20 Post by foxidrive » 06 Nov 2012 22:01

JFTR Windows doesn't have command line support for creating ZIP archives - you can only create .CAB archive files and there are limitations to those.

Post Reply