Easy compressing and extracting using batch files

PKZIP and PKUNZIP command line utilities for handling zip files, are not the most intuitive. Instead of having to remember the proper command line parameters, for either compressing files into a zip file, or to extract the files again from a zip file, then one can put them in a batch file.

Create a batch file called ZIP.BAT containing the following lines:

@ECHO OFF
REM *** If no parameters then compress all files into ZIPFILE.ZIP
IF “%1”==”” GOTO NONAME
REM *** If one parameter(filename) then compress all files into filename
IF “%2”==”” GOTO ALL

REM *** Both filename to compress to is given and files to compress ***
PKZIP -a -ex -r -P -whs %1 %2 %3 %4 %5 %6 %7 %8 %9
GOTO EXIT

:ALL
PKZIP -a -ex -r -P -whs %1 *.*
GOTO EXIT

:NONAME
PKZIP -a -ex -r -P -whs ZIPFILE.ZIP *.*

:EXIT

Create a batch file called UZIP.BAT containing the following lines:

@ECHO OFF
REM *** If no parameters then extract all the zip files ***
IF “%1”==”” GOTO ALL
REM *** If only one parameter given then extract to current directory ***
IF “%2”==”” GOTO HERE

REM *** Two or more parameters given, the 1st is the zip file, the 2nd is the destination ***
PKUNZIP.EXE -d %1 -o %2
GOTO EXIT

:HERE
PKUNZIP.EXE -d %1 -o .\
GOTO EXIT

:ALL
PKUNZIP.EXE -d *.ZIP -o .\UZIP\

:EXIT