# Compression Command-Line Tools

The Tools/Utilities downloads for DotNetZip includes a pair of command-line tools that perform raw compression and decompression: GZip.exe and BZip2.exe . These tools can be used from the command line to compress or decompress .gz and .bz2 files, respectively, from within batch scripts, or CMD.exe windows.

## GZip.exe

This tool can be used to compress a regular file into a .gz file, or to decompress a .gz files into its original, uncompressed form. It handles files in the .gz format created by other GZIP tools, such as the gzip tool that is included with Linux and other operating systems, and the .gz files it produces on Windows can be read by the gzip tool on other platforms.

Of interest, the GZip format handled by this tool is specified in IETF RFC 1952. While the GZIP format can handle multiple entries within a single archive, in general that feature is rarely used. Instead, most uses of GZip compress a single file to a single .gz file.

### Usage

      GZip.exe <FileToProcess> [arguments]

     arguments:
       -v         - verbose output.
       -f         - force overwrite of any existing files.
       -keep      - don't delete the original file after compressing or
                    decompressing it.

## BZip2.exe

This tool can be used to create .bz2 files, that conform to the BZIP2 format. Bzip2 was created in 1996 as a compression method and format that can be applied to single files. Unlike ZIP, it is not a multi-entry archive format - you use bzip2 to compress a single file into a single compressed image. By convention, for a given filename, a bzip2 compressor creates a new file called filename.bz2 .

Using the BZip2.exe command line tool included with DotNetZip, you can compress regular files into .bz2 files, and you can decompress .bz2 files into the corresponding original file.

This tool such is compatible with other bzip2 tools, such as the one that is included with Linux and other operating systems. The .bz2 files that this tool produces on Windows can be read by the bzip2 tool on other platforms.

Most Bzip2 utilities delete the original file after producing the compressed version, and delete the compressed version after decompressing. This utility follows that convention.

BZip2 is a compression format, similar to ZLIB, GZIP, or DEFLATE. BZIP2 tends to compress better than these other algorithms, but BZIP2 compressors tend to require more time to compress.

### Usage

    BZip2.exe <FileToProcess> [arguments]

      arguments:
        -v         - verbose output.
        -f         - force overwrite of any existing files.
        -keep      - don't delete the original file after compressing
                     or decompressing it.

### Command Examples

Use this Command... | to do this...
gzip.exe LargeFile.txt
| compress the LargeFile.txt to produce LargeFile.txt.gz .
gzip.exe LargeFile.txt.gz
| decompress the LargeFile.txt.gz to produce LargeFile.txt , and delete LargeFile.txt.gz .
gzip.exe LargeFile.txt.gz -keep
| decompress the LargeFile.txt.gz to produce LargeFile.txt ; the original LargeFile.txt.gz will not be deleted.
bzip2.exe LargeFile.txt
| compress the LargeFile.txt to produce LargeFile.txt.bz2 , and delete the LargeFile.txt when finished.
bzip2.exe LargeFile.txt -keep
| compress the LargeFile.txt to produce LargeFile.txt.bz2 , and keep the LargeFile.txt when finished.
bzip2.exe LargeFile.txt.bz2
| decompress the LargeFile.txt.bz2 to produce LargeFile.txt , and delete the original compressed file when finished.