This chapter describes the options Smartcrypt offers for extracting files from archives. These options give you various ways to choose what files to extract and where to extract them to and help you manage every aspect of extracting files.

# Default Values for Commands and Options

Commands and options that have sub-options generally have a default value. This is the sub-option value that is used if none is explicitly specified on the command line. For example, the default behavior for the extract command is to unzip or uncompress all files in an archive. This behavior is set with the all sub-option of the extract command.
See Chapter 8 for information on configuring default sub-option values for commands and options.

# Extracting New and Existing Files

You don't have to extract all the files included in a .ZIP archive. You can select files to extract and exclude files you do not need now. If the directory into which you extract the files contains files that have the same name as those being extracted, you have to decide if you want to overwrite those files.
Smartcrypt provides several ways to choose which files to extract. You can extract:

• All files in an archive (the all sub-option)
• Files that are not in the target extract directory plus files that are more recent versions of files that are in the extract directory (the update sub-option)
• Only files that are more recent versions of—that is, have the same names as—files that are already in the extract directory (the freshen sub-option)

## Extracting All Files from an Archive

extract=all
To extract all files from an archive file, type pkzipc -extract and the name of your archive file, as shown below:
pkzipc -extract test.zip
In this example, all files in the archive are extracted into the current directory.
By default, extract uses the all sub-option; you do not need to specify this sub-option unless you have changed the default for extract to some other sub-option.
The following example explicitly specifies the sub-option. This command does the same thing as the first example but also overrides any changed default setting. The override applies only to this instance of the command; it does not reset the default you have defined.
pkzipc -extract=all test.zip

## Extracting Newer Versions of Existing Files and New Files

extract=update
Update extracts to the target extract directory only files that are not already in the directory or are newer versions of files that are already there. Archive files that are older versions of files already in the directory are not extracted.
pkzipc -extract=update test.zip

## Extracting Only Newer Versions of Files

extract=freshen
Freshen extracts only files that are newer versions of files that already exist in the target extract directory. It does not add any files to the directory that are not already there in an earlier version.
pkzipc -extract=freshen test.zip

# Checking for Viruses when Extracting

avscan, avargs
Smartcryptcan use your anti-virus program to scan for viruses when you extract files.
The avscan option controls whether extracted files are scanned for viruses and specifies the anti-virus program to run to do scans.
When you extract with the avscan virus scanning option turned on, Smartcrypt first extracts the specified files and then runs the anti-virus program to recursively scan all files in the specified destination directory and its subdirectories. Smartcrypt relays to you any messages returned by the virus scanning program.
If your virus scanner is set up to scan files dynamically as they are read or written, you do not need launch a virus scan from Smartcrypt. Your virus scanner will automatically scan the files as they are extracted.
How your anti-virus program deals with files infected by a virus is determined by the way the program is configured and by the arguments, if any, included in the Smartcrypt command line used to run the scanner. The contents of the command line used to run the scanner and the arguments that may be available for it depend on your anti-virus program.
Use the Smartcrypt avargs option to specify any anti-virus command line arguments. To tell the anti-virus program what directory to scan, include the variable %e. Smartcrypt replaces this variable with the full path to the extraction directory before passing the command line to the anti-virus program.
The following example shows avscan used to run a virus-scanning program. The variable %e and arguments for the virus-scanning program's command line are given in the avargs option.
pkzipc -extract -avscan=f-prot.exe -avargs="%e /silent /nomem /noboot" myfiles.zip
In avscan, specify the full path to the anti-virus program if the executable is not on the search path.
Smartcrypt assumes that the anti-virus program will not launch any graphical interfaces that require user interaction and that the program will automatically clean up any viruses that it finds.
Most virus scanning programs return a value of 0 when a scan completes successfully and finds no viruses. If a program returns any other value as the result of a scan, Smartcrypt issues a warning that some of the extracted files may not have passed the scan.
Both avscan and avargs can be configured for use by default. Configuring avscan causes Smartcrypt to do virus scans by default whenever files are extracted, using the specified anti-virus program executable and whatever anti-virus command line arguments, if any, are given in avargs.

# Extracting from an Archive Embedded in an Archive

embedded
An archive can contain other archive files. For example, a ZIP file can contain other ZIP archives, or a GZIP archive might contain a TAR archive. Such contained archives are said to be embedded in the archive that contains them.
If Smartcrypt encounters a lone embedded archive file in another archive whose contents Smartcrypt is extracting, Smartcrypt prompts you whether you would like to extract the contents of the embedded archive or just the archive itself. For example, if Smartcrypt is extracting the contents of outerarchive.zip, and outerarchive.zip contains innerarchive.zip, Smartcrypt asks you whether you want to extract the files in innerarchive.zip or just innerarchive.zip itself.
The embedded option can be used with extract to tell Smartcrypt to omit the prompt and just go ahead and extract the files contained in any lone archive file embedded in an archive of the specified type. You must specify the type of the outer, container archive for which you want to extract files from embedded archives.
For example:
pkzipc -extract -embedded=zip outerarchive.zip
In the example, if outerarchive.zip contains a single embedded archive (it may also contain non-archive files), Smartcrypt extracts the files from the embedded archive instead of extracting the embedded archive itself, and does not prompt.
The embedded option can be configured to operate by default. For example, the following command line configures embedded so that files are routinely extracted from single archives (such as .tar archives) embedded in .gz files:
pkzipc -config -embedded=gz
Put a hyphen in front of the embedded sub-option to tell Smartcrypt not to prompt or extract the contents of an embedded archive in an archive of a specified type. A command line containing a hyphenated sub-option overrides a configured setting. For example, the following command line extracts only an embedded archive, not its files:
pkzipc -extract -embedded=-gz outerarchive.gz
Note that Smartcrypt extracts the contents of an embedded archive, with or without prompting, only if that archive is the only embedded archive in the outer archive file. If the outer archive file contains multiple embedded archives, the embedded archive files themselves are extracted.

# Extracting Passphrase-Protected Files

To extract files from a passphrase-protected archive, use the extract command with the passphrase option.

• If you specify the passphrase option without a passphrase, Smartcrypt prompts for a passphrase. For example:

pkzipc -extract -passphrase test.zip

When you press ENTER, a prompt appears:

Passphrase?

Type the passphrase. The characters appear on the screen as asterisks, for security. Press ENTER. If you specified the correct passphrase, the files will be extracted to the current directory. If the passphrase you entered is incorrect, a warning message displays:

 PKZIP: (W20) Warning! Incorrect passphrase for file: filename.ext

Retype your command line and when prompted enter the correct passphrase.
Note: Passphrases are case sensitive.

• If you do not specify the passphrase option when extracting an archive that contains passphrase-protected files, Smartcrypt prompts you as if you had included the passphrase command.
• Type the passphrase (preceded by an equal sign) as part of your command. For example:

pkzipc -extract -passphrase=mysecret test.zip
If the passphrase is correct, Smartcrypt extracts the files (to the current directory, by default). If the passphrase is incorrect, Smartcrypt displays a warning message:

PKZIP: (W20) Warning! Incorrect passphrase for file: filename.ext

Re-type your command line with the correct passphrase.
Note: For greater security, enter passphrases at the prompt so that asterisks hide the characters you are entering. For information on using passphrases in scripts, see Appendix E.
Note: Many other ZIP utilities can decrypt archives encrypted with traditional ZIP encryption. When a ZIP utility that can read strongly encrypted ZIP files is not available, use ZIP Reader.

# Authenticating Digital Signatures

When you extract files from an archive or test an archive with the test command, Smartcrypt authenticates any digital signatures attached to the files or the archive. A digital signature, like a pen-and-ink signature, warrants that the signed item really comes from the signer and has not been changed.
Use the test command on an archive to check for a signature before extracting files. Testing tells you whether files are signed, authenticates any signatures, and gives you information about certificates used to sign files. Smartcrypt authenticates signatures automatically when extracting.
Use the crl option to have Smartcrypt check an accessible certificate revocation list (CRL) to see if a certificate used for signing has been revoked. (See "Checking for Revoked Certificates" in Chapter 3.)
Signatures can be applied to particular files and/or to the central directory of an archive (that is, to the archive itself).
The following table lists warning messages that can appear when you test or extract signed files, causing Smartcrypt to authenticate signatures.

Message

Explanation

What to do?

Signature is invalid

The file or archive has changed since it was signed.
The archive may be corrupt.

You may want to try to obtain the file again (for example, download the file again from the Web site).
Contact the archive creator as the file/archive has been compromised. If the file was downloaded from a Web site, you may want to contact a person at that company about the file.
If a file has an invalid signature, then the file may have been modified.
If the central directory has an invalid signature, then file(s) have been modified, added or deleted from the archive since the archive was signed.

Certificate is not trusted

The certificate used to sign is currently not to be trusted.

This message indicates that the certificate is not to be trusted, but there may be no problem with the archive.
Contact the issuer of the certificate to validate the certificate/signature.

Certificate is expired

The certificate has expired (perhaps because the archive was signed a long time ago).

Contact the owner of the certificate.
This message indicates that the certificate is not to be trusted, but there may be no problem with the file or archive.

Certificate is revoked

Indicates the issuer has revoked the certificate.

Contact the issuer or owner of the certificate.
This message indicates that the certificate is not to be trusted, but there may be no problem with the file or archive.

The certificate for the signature could not be found on your system.

Check to see if the certificate name was misspelled.
Confirm that the certificate is on the system.

# Extracting Only Trusted Archives

verifysigner
With the verifysigner option, you can set Smartcrypt to extract an archive only if the archive is signed using one of a specified set of certificates or OpenPGP keys. If the verifysigner option is used, Smartcrypt will extract an archive only if these two conditions are met:

• The archive central directory is signed using a certificate specified with the option
• Smartcrypt can find a copy of each certificate specified with the option, containing the public key, in the local store (X.509 and OpenPGP) or a specified LDAP directory (X.509 only)

For example, the following command line extracts only if the archive is signed by John Smith, and Smartcrypt can find the certificate used to sign:
pkzipc -extract -verifysigner="John Smith" important.zip
You can use the option multiple times in the same command line to specify more than one acceptable, trusted signer:
pkzipc -extract -verifysigner="John Smith" -verifysigner="Jane Doe" important.zip
The command line above extracts if the archive is signed by either John Smith or Jane Doe, but certificates for both John Smith and Jane Doe must be found.
The requirement that Smartcrypt be able to find a copy of a signer's certificate locally (or on a directory server) ensures that the signer is the person you think he is. If Smartcrypt only authenticated the signature without also checking its certificate, you would know that an archive really was signed by someone named John Smith, but you would not know if this John Smith is the same John Smith whose certificate you have.

## Specifying Trusted Signers

You can specify a list of trusted certificates/signers either by specifying each certificate individually on the command line or by specifying a file that contains a list.
By default, Smartcrypt searches for certificates for listed recipients only in the system's local certificate stores. Use the ldap option to cause Smartcrypt to search a specified LDAP directory in addition.

### Specifying Trusted Signers Individually

You can specify a trusted signer using any of the following criteria:

Criterion

To use

For example

Common name

Specify, in quotes, the common name of the subject of the certificate (that is, the cn field in a string representation of a certificate); optionally, precede with:
cn=
By default, Smartcrypt searches for certificates by common name unless another sub-option is used or the value appears to be an email address.

-verifysigner=cn="John Public"
-verifysigner="John Public"

Keyid (OpenPGP)

Specify the KeyID of an OpenPGP key; optionally precede the KeyID with
0x

-archiveType=pgp -verifysigner=kid="XXXXXXXXXXXXXXXX"
-verifysigner=0x XXXXXXXXXXXXXXXX

Specify the email address of the certificate (that is, the e field in a string representation of a certificate); optionally, precede with:
e=
Smartcrypt automatically looks for an email address if the string contains an @ and a dot and looks like an email address.
Note that a certificate must contain an email address in order to be found by this method. Not all certificates embed an email address.

-verifysigner=e=john.public@xyz.com
-verifysigner=john.public@xyz.com

LDAP filter

Specify the LDAP filter that you want to use to filter a search for certificates on an LDAP server that you are accessing with the ldap option; precede with:
f=
Use quotes if the filter string contains a space. Place the quotes around the entire filter string, including "f=".
Include the following LDAP presence filter, as shown in the examples at right, to limit the search to LDAP entries that are certificates:
(&(userCertificate=*)(…))
Use standard LDAP filter syntax after the "f=" prefix.
This sub-option is for use only when the ldap option is used.

-verifysigner=f=(&(userCertificate=)(ou=Sales))*
-verifysigner="f=(&(userCertificate=)(ou=Regional Sales))"*

### Specifying a File That Lists Trusted Signers

Smartcrypt can extract a list of certificates from these kinds of files:

• An ordinary text file that lists the common name of each certificate on a line by itself

To use the verifysigner option to specify an ordinary text file list as a sub-option, prefix the file name with the listfile character (@, by default):
pkzipc -extract -verifysigner=@my_list_file.txt test.zip

• A PKCS#7 file: These kinds of files can contain one or more actual certificates. PKCS#7 files have the file name extensions .p7b and .p7c and do not contain private keys, only public ones.

To use the verifysigner option to specify one of these types of file to define a list comprising the owners of the certificates in the file, prefix the file name with a hash (#) character:
pkzipc -extract -verifysigner=#my_cert_file.p7b test.zip
The verifysigner option can be configured for use by default.

# Extracting an Archive on STDIN or a Special File

Ordinarily, when you use the extract command to extract files from an archive, you extract the files from a physical archive file. For example, the following command line extracts all .txt files from the archive myfiles.zip:
pkzipc -extract myfiles.zip *.txt
Smartcrypt can also extract files from an archive that is not a physical file but is presented from an input source such as STDIN or a named pipe.
Note: Some options are not supported when extracting from an archive that is not a physical file. In particular:

• Signatures (added with the sign option) on either files or the archive central directory are not processed.
• Because signatures are not processed, the verifysigner extraction option always fails. (This option requires verification that an archive was signed using a specified certificate.)
• File name encryption (cd option) is not supported.

## Extracting from an Archive on STDIN

You can specify STDIN (standard input) instead of a physical file as the location or source of an archive from which to extract files. To do so, use a hyphen "-" in place of the name of an archive file. In a command line with the extract command (or the test or view command), the hyphen tells Smartcrypt to read the archive from STDIN. For example:
pkzipc -extract -noarchiveextension -silent=input -
or (UNIX):
cat file.zip | pkzipc -view -noarchiveextension -silent=input -
The noarchiveextension option is needed so that Smartcrypt does not take the hyphen as a file name and try to extract from a file named .zip. If the archive is not a ZIP archive, use the archivetype option to specify its type. For example, the following command line tells Smartcrypt that the file is a BZIP2 archive:

pkzipc -extract -archivetype=bzip2 -noarchiveextension -silent=input -

or (UNIX):
cat file.bz2 | pkzipc -view -archivetype=bzip2 -noarchiveextension -silent=input -
The silent option is set to the input sub-option to suppress any Smartcrypt requests for input (a passphrase, for example). If input is needed, the extraction fails with an error.
See "Writing an Archive to STDOUT" in Chapter 4 for a way to create an archive that is presented through STDIN.

## Extracting an Archive from a Named Pipe, UNIX Domain Socket, or Device File

You can specify a named pipe, UNIX socket, or device file instead of a physical file as the location of an archive from which to extract files. The pipe, socket, or device must first be created, perhaps by another program, and an archive must be written to it. To extract, use the name of the pipe, socket, or device in the command line in place of the name of an archive file. For example:
pkzipc -extract -noarchiveextension <name of pipe or socket>
As when extracting from STDIN, you must use the noarchiveextension option to prevent Smartcrypt from trying to extract from a .zip file—in this case, one named for the pipe or socket.
Smartcrypt tries to extract from ZIP-format archives by default. To extract from a different type of archive, use the archivetype option to specify the type. For example, the following command line tells Smartcrypt that the archive is a BZIP2-format file:
pkzipc -extract -archivetype=bzip2 -noarchiveextension <name of pipe or socket>
You must use the full UNC path when referring to a named pipe on Windows. For example:
pkzipc -extract -noarchiveextension \\.\pipe\mypipe *.doc
In the preceding example, the dot in the path
\\.\pipe\mypipe
references the current machine. To reference a pipe on a different machine—named boulder—specify the machine.
\\boulder\pipe\mypipe
You can use either a name or an IP address to specify a machine.
You must use the noarchiveextension option to prevent Smartcrypt from trying to extract from an archive file named .zip.
On UNIX, use the timeout option to have Smartcrypt wait a specified number of seconds before checking a socket or device for more data.

# Extracting Data to STDOUT or Special Files

"Adding Data from STDIN or Special Files" in Chapter 4 describes how to capture data from STDIN or such special files as named pipes or UNIX sockets and add it to an archive. Files can also be extracted from an archive to STDOUT or to special files.
To extract to STDOUT, use the console command (see "Extracting Files Only for Display" later in this chapter for more on console). To extract to special files, you can use either console or extract.

## Extracting to STDOUT

To extract to STDOUT, use the console command instead of extract.
By default, the console command writes a Smartcrypt banner of text at the beginning of the output; it also inserts a file header containing the name of the file before each file's data, like this:

============================== output.txt ==============================

To suppress the banner, use the silent option with the banner sub-option. To suppress the file header as well, append the fileheader sub-option. The command line below writes only the data from output.txt to STDOUT.
pkzipc -console -silent=banner,fileheader data.zip output.txt

## Extracting to Special Files

By redirecting its output, you can also use the console command to extract data to a named pipe or UNIX socket.
The console command has the limitation that all output goes to one place: multiple files cannot be extracted to multiple destinations—different pipes, for example—using a single command line. To extract to one or more special files, use extract with the stream (UNIX) or rename option (Windows) instead of using console. Extracting to Special Files on UNIX
The following command line extracts all files in an archive to a UNIX pipe or socket file named mystream:
pkzipc -console -silent=banner,fileheader data.zip > mystream
To extract archived data to a special file on UNIX, use extract with the stream option to extract to a pipe or socket file.
The following command line extracts mystream either to an existing pipe named mystream or, if no such pipe exists, to an ordinary file named mystream.
pkzipc -extract -stream data.zip mystream
If the stream option is omitted, the file is extracted as an ordinary file, and any existing mystream pipe is removed.
The following command line extracts multiple files to multiple pipes:
pkzipc -extract -stream data.zip mystream otherstream
You can use the rename option to rename the extracted files to match the names of their intended targets. For example, if data.zip contains the files myinfo and otherinfo, the following command line renames the extracted copies to mystream and otherstream to enable them to extract to pipes having those names:
pkzipc -extract -stream -rename=/info/stream/ data.zip mystream otherstream
The rename option can be used multiple times in a command line. See "Displaying Security Information of the ZIP File" in Chapter 7.

### Extracting to Named Pipes on Windows

On Windows, named pipes are all located in the same pipe folder on each system: \\<machine_name>\pipe\. The following command line uses the console command to extract file mystream and redirects the output from STDOUT to the pipe named mystream on the local system:
pkzipc -console -silent=banner,fileheader data.zip mystream > \\.\pipe\mystream
The dot (.) indicates the local system. To reference a pipe on another system, specify the machine name:
pkzipc -console -silent=banner,fileheader data.zip mystream > \\boulder\pipe\mystream
To extract to a named pipe on Windows, you must use the rename option with extract. The stream option is not used.
You cannot save the Windows named pipe path in the archive, but you can specify it on extraction using rename. Extracting a file to an identically named pipe places the data in the pipe and preserves the pipe. A file extracted to a folder that does not contain an identically named pipe file extracts as an ordinary file.
The following example renames a file myinfo to match the name of a \\.\pipe\mystream pipe on the local system. The rename option uses the backslash as an escape character even in the replacement expression, so each backslash must itself be preceded by a backslash for Smartcrypt to see it as a literal character:
pkzipc -extract -rename=/myinfo/\\\\.\\pipe\\mystream/ data.zip mystream
See "Renaming Files" in Chapter 7.

# Extracting to Dynamically Named Folders

substitution
With the substitution option, you can extract the contents of an archive to a folder whose name and path are constructed on the fly from tokens embedded in the specification for the destination folder on the command line. Smartcrypt creates the actual name of the folder by substituting values for the tokens when the archive is extracted. Tokens are supplied that enable you to name the folder after the archive to be extracted to it, replicate the path to the archive, and embed timestamp elements.
With this option, you can use a single command line to extract multiple archives each to its own custom-named folder.
The table below lists the tokens for use with the substitution option when extracting.

Token

Replaced by

{archivename}

Base name of archive, without the extension

{archiveext}

The file name extension of the archive

{archivepath}

The path of the archive, without the file name, preceded by a slash or backslash and excluding the drive letter or share path if the name is a UNC name

{id}

A job ID specified separately with the jobid option. For example, if run in 2006:
pkzipc -add -jobid=myJob -substitution {id}{yyyy}.zip *.doc
produces a ZIP file named:
myJob2006.zip

{mm}

Month, 2-digit

{m}

Month, 1-digit (if possible); no leading 0

{dd}

Day, 2-digit

{d}

Day, 1-digit (if possible); no leading 0

{yyyy}

Year, 4-digit

{yy}

Year, 2-digit

{HH}

Hour, 2-digit, 24-hour format

{H}

Hour, 1-digit (if possible), 24-hour format

{hh}

Hour, 2-digit, 12-hour format

{h}

Hour, 1-digit (if possible), 12-hour format

{MM}

Minute, 2-digit

{M}

Minute, 1-digit (if possible); no leading 0

{SS}

Second, 2-digit

{S}

Second, 1-digit (if possible); no leading 0

{ampm}

a.m. or p.m. indicator to identify current 12-hour segment of the day

The following command line shows a straightforward example of the substitution option. The command line extracts all ZIP files in the current directory, each to a subdirectory named after the ZIP archive extracted there. If two ZIP files, myfiles.zip and myfiles2.zip, are in the current directory, the command line extracts them to subfolders named myfiles and myfiles2, respectively.
pkzipc -extract -substitution *.zip {archivename}\
The example below uses the {archivepath} token to specify the archive path for the destination folder. The {archivepath} token includes a leading backslash (or slash). The command line extracts all ZIP files in folder \home\thomas\ each to its own subfolder in other\location\home\thomas\. For example, it extracts myfiles.zip in folder \home\thomas\ to subfolder other\location\home\thomas\myfiles.

pkzipc -extract -substitution \home\thomas\*.zip \other\location{archivepath}\{archivename}\

Most UNIX shells treat { and } and * as metacharacters, which need to be escaped for the command line to work properly. To be safe, put the whole file name or path name in quotation marks when using the substitution option on UNIX.
Formatted for UNIX, the preceding example looks like this:

pkzipc -extract -substitution "/home/thomas/*.zip" "/other/location{archivepath}/{archivename}/"

If run from C:\myproject, the command line below extracts all ZIP files to C:\myproject\test. The dot in the specification for the target folder locates the start of the extraction path in the current folder. The drive letter is stripped.

pkzipc -extract -substitution D:\test\*.zip .{archivepath}\

If the date is July 31, 2008, and the directory C:\app1\ contains myfiles.zip and test2.zip, the command line below extracts test1.zip to folder test1-07312008 and test2.zip to folder test2-07312008:
pkzipc extract -substitution C:\app1\*.zip {archivename}-{mm}{dd}{yyyy}\
The following example shows how {archivepath} strips out a share path. If \\server\share\path\to\zips contains test1.zip and test2.zip, and the current directory is d:\testme, the command line extracts test1.zip to d:\path\to\zips\test1 and extracts test2.zip to d:\path\to\zips\test2:

pkzipc -extract -substitution \\server\share\path\to\zips\*.zip {archivepath}\{archivename}\

The example below uses the substitution option when extracting an archive from STDIN, represented by a hyphen in the command line (see "Extracting an Archive on STDIN or a Special File"). If the date is July 31, 2008, an archive provided on STDIN is extracted to directory -07312008. In this case, {archivepath} and {archiveext} are replaced with nothing, and {archivename} is replaced with a hyphen.
pkzipc -extract -substitution -noarchiveextension - {archivepath}\{archivename}{archiveext}{mm}{dd}{yyyy}
The substitution option can also be used with the add command and a slightly different set of tokens to insert a timestamp in the name of a newly created or updated archive. See "Inserting a Timestamp in the Archive File Name" in Chapter 7.

# Extracting Files in Lower Case

lowercase
The lowercase option allows you to extract files in lower case regardless of how the file name was originally archived. To force the file names to be extracted in lowercase, use the following example:
pkzipc -extract -lowercase test.zip

# Changing Ownership When Extracting (UNIX)

id
By default, Smartcrypt stores the UID and/or GID of the user who adds a file. When extracting, Smartcrypt gives files the UID and GID of the user performing the extraction. The id option restores files' original ownership when extracting.

pkzipc -extract -id=userid test.zip

To use the id option, you must be either the super user or the user listed in the archive as the owner of the file.
The id option is configurable.
owner
The owner option can be used when adding or extracting files. The option changes files' associated UID and/or GID to a specified UID or GID. The following example specifies both. It sets the owner to jon and the group to eng.
pkzipc -extract -owner=jon:eng test.zip
When adding files, you can use the option to mask off your ownership information. For example, the following command line marks files as owned by the root account.

pkzipc -add -owner=0:0 test.zip

To use the owner option when extracting, you must be either the super user or the user listed in the archive as the owner of the file.
When extracting files, you can use the option to mark the files as owned by someone else.
The owner option is configurable.

# Preserving File Times

times
The times option allows you to preserve the access, creation and modification times of the extracted files. Specify the sub-option all to preserve all times, use access to preserve the access times only, use modify to restore the time of last modification times or create to restore the creation times.
To preserve all the file times, use the following example:
pkzipc -extract -times=all test.zip
Note: On UNIX systems, no creation time is preserved, as most UNIX file systems do not track when a file was created.

# Retaining Directory Structure while Extracting

directories
If you stored directory path information within a .ZIP file, you can re-create those directory paths when you extract the files. For example, if you compressed a file called apples.doc in the temp/fruit directory, and you stored temp/fruit you can re-create temp/fruit in the location in which you extract the files.
To re-create directories, use the directories option with the extract command, as in the following example:
pkzipc -extract -directories test.zip
When you use this command, all directories that were stored in the .ZIP file will be retained during extraction. The directory path stored is appended to the directory in which you extract the files. For example, if your extract directory is /doc, and a directory path stored with the files is temp/fruit, the files would now be extracted to /doc/temp/fruit.

zoneidentifier
When you download a file from any other computer with Microsoft Internet Explorer, the browser attaches "security zone" information about the computer hosting the file. These zones are labeled Local Intranet, Trusted Sites, Internet, and Restricted Sites. As a result of this "zone identifier," you may receive a warning about files received from the Internet from Windows before you open or activate the file, depending on your Internet Options settings.
By default, Smartcrypt does not retain this information when you extract files from an archive that contains this information. The zoneidentifier command allows you to preserve that information if you are extracting from an NTFS-formatted drive to another NTFS-formatted drive.
Note: Only NTFS volumes can preserve and process Zone Identifier information. Volumes created with FAT (the default file system for Windows 98 and earlier), or UNIX-based file systems will not preserve this alternate stream. This would include files saved in IE to temporary directories on non-NTFS systems.
To specify that all extracted files in MyDownloadedFiles.zip retain its Zone information, type:
pkzipc -extract -zoneidentifier MyDownloadedFiles.zip
To configure Smartcrypt to preserve the Zone information whenever possible, use this command:
pkzipc -config -zoneidentifier=enable

# Sorting Files in the Extract Directory

sort
Smartcrypt allows you to specify the sort order of files that are compressed in a .ZIP file or extracted into a destination directory. For example, if you wish to extract files in a specified sort order (by date), you would type the following and press ENTER:
pkzipc -extract -sort=date test.zip
In this example, all files that exist in the test.zip file are extracted into the current directory sorted in ascending order by date. For more information on sort options, see Appendix A.

# Extracting Files Only for Display

console
Smartcrypt gives you the option of displaying specific files contained in a .ZIP file to your computer monitor. For example, if you wish to view the contents of all of the .txt files contained in a .ZIP file, type the following and press ENTER:
pkzipc -console test.zip *.txt
In this example, all files with a .txt extension that exist in the test.zip are displayed on the monitor. Since many .ZIP files contain an information document (such as readme.txt), the console option is a good way to determine the contents of a .ZIP file without requiring you to extract a file or file(s) to your hard drive.
Note: You can also use the console and silent options to redirect files to pipe files directly to another program on UNIX and Windows XP (and later) systems.

# Extracting Files with a List File

You can use a list file to specify files to extract from an archive. In the list file, specify file and path name information to identify the target files. You can explicitly list individual files to extract, or use wild card characters (*, ?) to specify multiple files in a single entry. For example, entries like the four below are permitted:

Fred\My Documents\tmp\yparent\ychild\ychild1.txt Documents and Settings\Fred\My Documents\tmp\yparent*.txt dparent?.txt *.xls

How you identify files in an archive depends on the path information that was archived with them. In an archive, path information is treated as part of a file name for purposes of identification. So d*.txt does not just get all .txt files whose names start with d in the root folder of an archive; it gets all .txt files whose pathname starts with d. For example, it would get these files:

 Documents and Settings\Fred\My Documents\tmp\yparent*.txt dparent?.txt

Do not use drive letters in a list file used to extract. Drive letters are not saved with other path information in an archive and are not allowed in extraction list file entries.
To specify a list file to use to extract, prefix the pathname of the list file with the @ character on the command line after the name of the archive. For example, the following line extracts using list file mylist.txt:
pkzipc -extract test.zip @tmp\mylist.txt
See the listfile option for information on using this option to create a list file. See the view option for information on viewing path information saved in an archive.