Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: zipping files with batch file  (Read 3992 times)

0 Members and 1 Guest are viewing this topic.

Luis Ribeiro

  • Guest
zipping files with batch file
« on: September 07, 2005, 08:39:42 AM »
Hello. I'd like to create a batch file that uses Power Archive to zip 2 .txt files into one archive.
The name of this archive should contain the system date.

Can anyone help me on this issue ?

Thanks
Luis

R W

  • Guest
Re: zipping files with batch file
« Reply #1 on: September 08, 2005, 12:14:40 PM »
I have done this before, but it is a little involved.

First you should make sure that Power Archive has command line capability.

If that's good, then here is code that I used with pkzip some time ago:


Code: [Select]

@cls
REM @echo off
REM
REM Batch File Name:
REM      SCHED_BACK.BAT
REM
REM Description:
REM      Compress files and subdirectories on Development
REM      into a file to be backed up.
REM
REM      Functions:
REM            1) Calls Sched_back_date to set Sched_back_DATE variable
REM            2) Backup files using PKZIP
REM
REM      Parameters:
REM            1) Day of Week (Abbreviated - Mon, Tue, etc)
REM
REM
REM Modifications:
REM     16-Oct-1998 R. Willard initial version                  
REM     13-Aug-1999 R. Willard Added backup for Web directories
REM                           Backup file now contains day of week
REM
REM ========================================

...

CALL Sched_back_date

SET Sched_back_FILE=backup_%Sched_back_DATE%.zip

\Pkzip\pkzip25 -Add -Dir=specify %Sched_back_FILE% "\folders\files.txt"


 
This is how I set the date, you will want to make sure you have QBASIC to do this.

Code: [Select]

REM      Batch File Name:
REM            SCHED_BACK_DATE.BAT
REM
REM      Description:
REM            Sets sched_back_DATE environment variable for use in
REM            Sched_back for naming the backup file.
REM
REM            Functions:
REM                  1) Writes basic commands to $sbd$.bas
REM                  2) Run $sbd$.bas using Qbasic
REM                  3) Builds $sbd$.bat which is called to set variable
REM
REM            Parameters:
REM                  1)
REM
REM      Modifications:
REM            4-Nov-1998      R. Willard      initial version                  
REM
========================================
REM
echo>$sbd$.bas open "$sbd$.bat" for output as #1
echo>>$sbd$.bas ? #1, "set Sched_back_DATE=";DATE$
echo>>$sbd$.bas done:close #1:system
qbasic /run $sbd$.bas
call $sbd$.bat
del $sbd$.ba?


Hope that is of some use.  Can't believe I found this code on one of my many backup CDs.