Using PKzip and PKunzip - The Basics
by Brock Wood
Table of Contents
Introduction: About This TutorialSo you want to know more about using pkzip to compress files into "ZIP" format archive files? Well, you have come to the right place. As you probably already know, the ZIP format is the most popular format for compressing files on an IBM PC. "Pkzip" is a DOS program that will compress files into a ZIP archive file, saving valuable disk space. If you intend to transfer the ZIP file by modem, you also save valuable on-line time. The companion program, pkunzip, will extract the original files from a ZIP file. Many files that are available for download on the internet are stored as ZIP files to minimize your download time.
In this tutorial, I will explain how to do the four tasks most people want to accomplish with PKzip/PKunzip:
Part 1. Downloading and Installing PKzip and PKunzipUnless you have it installed on your computer already, the first thing you need to do is to download the PKzip for DOS package, version 2.04g, to your hard drive. PKzip version 2.04g is available in a self-extracting file named pkz204g.exe. You can download the pkz204g.exe file (approximately 200K) from this web site:
Now you need to go to the DOS prompt for a while. In Windows 3.1, double click on the "MS-DOS" icon in the "Main" group. In Windows 95, click on "Start," "Programs," and "MS-DOS Prompt."
Are you at the DOS prompt? Good. Now, did you remember where the pkz204g.exe file downloaded to? No? If not, it is not a big problem. Just go to the root directory of your hard drive and do a search for it:
The "dir /s" command will tell you the directory to which you downloaded pkz204g.exe. (If you downloaded it to a drive other than C:, substitute the appropriate drive letter for the "C:" in the command above). Jot down the "Directory of" result from the "dir /s" command on a piece of paper. Now, let's create a new directory on the C: drive for the pkzip and pkunzip files:c: [ENTER]
The "md" command, above, creates a new directory called "zipstuff" in the root directoy of the C: drive.md c:\zipstuff [ENTER]
Now, copy the pkz204g.exe file into the c:\zipstuff directory:
Substitute the name of the directory path to which you downloaded pkz204g.exe for "[directory path]" in the command above. For example, if you downloaded pkz204g.exe into "c:\mystuff\download", then substitute "c:\mystuff\download" for "[directory path]".copy [directory path]\pkz204g.exe c:\zipstuff [ENTER]
Now, let's change to the c:\zipstuff directory using the "cd" command:
Run pkz204g.exe to extract the pkzip and pkunzip program files:cd\zipstuff [ENTER]
When you run pkz204g.exe, you should see several files extract themselves into the c:\zipstuff directory. Now you need to copy three files, "pkzip.exe," "pkunzip.exe," and "zip2exe.exe," to a directory in your system "path." The reason you want to put these files into a directory in your path is that, when they are in a directory in your path, you can use them from anywhere on your system. Normally, the "c:\windows" directory is in your path, so we'll copy the files there:pkz204g [ENTER]
If the "c:\windows" directory doesn't work, you can try the "c:\dos" directory (DOS-only system) or the "c:\windows\command" directory (Windows 95 system).copy pkzip.exe c:\windows [ENTER]
Great! You have successfully installed the pkzip and pkunzip program files onto your hard drive!
Part 2. Zipping Up a ZIP File with PKzipNow you are ready to starting creating ZIP files! Let's make a new directory and copy a few files into it so that you can experiment with pkzip:
The copy command, above, copied all the files ending in .INI from the c:\windows directory into the c:\ziptest directory. Now, let's go into the c:\ziptest directory:md c:\ziptest [ENTER]
Let's zip up all of those .INI files into a ZIP archive file called "first.zip". To do that, we use the pkzip program:cd\ziptest [ENTER]
Using a "dir" command to see a list of the files in the c:\ziptest directory, you can see that a new file, "first.zip," has been added to the directory:pkzip first.zip [ENTER]
See it? Good. The first.zip file contains all of the .INI files that are in this directory. The files are stored in compressed form - they take up much less space when stored in the first.zip file than when they are stored individually in the directory.dir [ENTER]
Let's clean up by deleting all of the .INI files in this directory using the "del" command:
All that's left in the directory is the first.zip file. Let's do a "dir" command to confirm that:del c:\ziptest\*.ini [ENTER]
Congratulations! You just created your first ZIP file! Consider yourself a bona fide "hacker"!dir [ENTER]
Part 3. Unzipping a ZIP File with PKunzipNow, let's "unzip" the first.zip file using pkunzip. All of the .INI files will be extracted from the first.zip file back into the c:\ziptest directory:
Do another dir command and you can see that the .INI files are back!pkunzip first.zip [ENTER]
Neat, huh? The easiest way to unzip a ZIP file that is on a floppy disk is to first create a new directory on your hard drive for the ZIP file and then copy it to the new directory. When you unzip the ZIP file, the resulting files are extracted into a new directory you created expressly for that purpose and don't get mixed up with other files that are already on your hard drive.dir [ENTER]
Part 4. Putting a ZIP File onto Multiple Floppy DisksNow let's learn how to use pkzip to create a ZIP file that spans multiple floppy disks. Change to a directory that has at least 3 to 5 megabytes of files in it (the c:\windows directory is a good choice):
In the c:\windows directory, you will probably find several megabytes of .EXE files. We can zip up all of these .EXE files and put the resulting ZIP file onto multiple floppy disks. The key is to use the pkzip program with the "-&" switch:cd\windows [ENTER]
You may need to feed several blank, formatted floppy disks into the A: drive! If you run out of disks, just press "Ctrl-C" to cancel the zipping operation.pkzip a:\allexe.zip *.exe -& [ENTER]
In the example above, you specified that you wanted to create a new .ZIP file named "allexe.zip" on the A drive. The "*.exe" portion of the command told pkzip to include only .EXE files in the new ZIP file. The "-&" portion of the command told pkzip that allexe.zip might span multiple floppy disks.
Pkzip can compress most program files, such as .EXE, .COM, and .DLL files by about 50 percent. When compressing text files, such as .INI and .TXT files, pkzip can sometimes compress the file by 80 to 90 percent!
Part 5. Making Self-Extracting ZIP FilesIf you are giving a compressed ZIP format file to another person who will be responsible for unzipping it, you might want to give the person a "self-extracting" ZIP file. A self-extracting ZIP file is just a regular ZIP file that has been converted to a .EXE file. When you run the .EXE file, the compressed programs are extracted. This eliminates the need to give the recipient a copy of pkunzip with the ZIP file (as well as the need to teach the recipient how to use pkunzip). In fact, the pkz204g.exe file, which contains the pkzip and pkunzip program files, is a self-extracting ZIP file!
To create a self-extracting ZIP file, you must first create a normal ZIP file. Then you run the zip2exe program on the ZIP file and a self-extracting file is created.
Let's use the the first.zip file we created in part 2, above, as our example. First, we need to change to the the c:\ziptest directory (if you aren't in it already):
To convert first.zip to a self-extracting ZIP file, use this command:cd\ziptest [ENTER]
Do a dir command to see the resulting .EXE file, "first.exe":zip2exe first.zip [ENTER]
To extract the files from first.exe, just run the file:dir [ENTER]
Finis: For More InformationWell, now you know the basics of PKzip and PKunzip. If you need further help with PKzip and PKunzip, there is a manual you can consult. It is in a text file called "manual.doc" that comes with the pkz204g package. It should have been extracted into the "c:\zipstuff" directory that we created in part 1 of this tutorial. You can open manual.doc with your favorite text editor or word processor and read it and/or print it out.
- Brock Wood