Saving Partial Path Info with WinZip

By Mitch Stuart
Copyright © 2001-2003 FullSpan Software  -  Usage subject to license
Document Version: $Revision: 1.3 $, $Date: 2004/01/28 05:40:26 $

The popular WinZip utility (http://www.winzip.com) makes it easy to store a file with none of its directory path information, or all of its path info -- but storing a file with only partial path info takes a little extra work. This article explains how to store a file with some -- but not all -- of its directory path information.

It is often useful to include path information with a file that you are adding to a Zip archive (.zip, .jar, etc.).  Usually you do not want the full path of the file (e.g., d:\mydir1\mydir2\foobar.txt) stored in the archive, but rather the path from some root point (e.g., mydir2\foobar.txt).  This allows you to unzip the archive in an arbitrary destination, and maintain the correct hierarchy of the directories and files.

Let's say you want to add the following file to a .jar archive:

  D:\projects\net\build\classes\org\apache\soap\util\net\HTTPUtils.class
and you want the directory information to begin from the root of the Java package.  In other words, you want the file to appear in the achive as:

  org\apache\soap\util\net\HTTPUtils.class

To accomplish this, bring up the WinZip "Add" dialog as shown below:

Now perform the following steps:

1.  Use the directory navigator to navigate to the directory just above the topmost directory that you want stored with the filename.  In this example, the topmost directory that we want stored is org, so we would navigate to the classes directory just above org.

2.  Enter the file name specification for the file(s) that you want to store.  Even if you are only storing one file and you know its exact name, you must use a wildcard character so that the next two steps can be performed.  You can just add a * at the end of the filename or in place of any characters in the filename.  Just be sure that the file specification, including the wildcard, will find only the file(s) that you want to add, to avoid adding unwanted files.

3.  Check the "Include subfolders" checkbox.  Do not check the "Save full path info" checkbox – this will save the full path (except for the drive letter) – in the current example it would save:

  projects\net\build\classes\org\apache\soap\util\net\HTTPUtils.class

which is not what we want in this case.

4.  Click the "Add with wildcards" button.

The file(s) will be added with the desired path information as shown below: