> For the complete documentation index, see [llms.txt](https://docs.b2winsuite.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.b2winsuite.com/5.6/scripting/utilities/compressionutil.md).

# CompressionUtil

`CompressionUtil` provides utility methods for compressing and decompressing files in various formats such as TAR.GZ and ZIP. It offers functionalities to compress multiple files into a single archive and to decompress archives into specified directories.

## Methods

#### `compressTarGzipFile(File: inputFile, String: outputFileName): File`

Compresses file into a single TAR.GZ file.

*@param*`inputFiles` — - A file path to be compressed.

*@param*`outputFileName` — - The name of the output TAR.GZ file.

*@returns* — The File with the compressed ZIP file.

```javascript
// Read a file
var filePath = "path/to/your/file.txt";
var file = FileUtil.readFile(filePath);
CompressionUtil.compressTarGzipFiles(file, "generatedTarGZFileName");
```

#### `compressTarGzipFiles(File[]: inputFiles, String: outputFileName): File`

Compresses multiple files into a single TAR.GZ file.

*@param*`inputFiles` — - An array of file paths to be compressed.

*@param*`outputFileName` — - The name of the output TAR.GZ file.

*@returns* — The File with the compressed ZIP file.

```javascript
// Read a file
var filePath = "path/to/your/file.txt";
var file = FileUtil.readFile(filePath);
CompressionUtil.compressTarGzipFiles([file], "generatedTarGZFileName");
```

#### `compressZipFile(File: inputFile, String: outputFileName): File`

Compresses file into a single ZIP file.

*@param*`inputFile` — - A file path to be compressed.

*@param*`outputFileName` — - The name of the output ZIP file.

*@returns* — The File with the compressed ZIP file.

```javascript
// Read a file
var filePath = "path/to/your/file.txt";
var file = FileUtil.readFile(filePath);
CompressionUtil.compressZipFiles(file, "generatedZipFileName");
```

#### `compressZipFiles(File[]: inputFiles, String: outputFileName): File`

Compresses multiple files into a single ZIP file.

*@param*`inputFiles` — - An array of file paths to be compressed.

*@param*`outputFileName` — - The name of the output ZIP file.

*@returns* — The File with the compressed ZIP file.

```javascript
// Read a file
var filePath = "path/to/your/file.txt";
var file = FileUtil.readFile(filePath);
CompressionUtil.compressZipFiles([file], "generatedZipFileName");
```

#### `decompressTarGzipFile(File: inputFiles, String: outputDirName): File`

Decompresses a TAR.GZ file into a specified directory.

*@param*`inputFile` — - The path of the TAR.GZ file to be decompressed.

*@param*`outputDirName` — - The name of the output directory.

*@returns* — A File path of the output directory.

```javascript
// Read a file
var filePath = "path/to/your/file.tar.gz";
var file = FileUtil.readFile(filePath);
CompressionUtil.decompressTarGzipFile(file, "uncompressedTarGZDirName");
```

#### `decompressZipFile(File: inputFiles, String: outputDirName): File`

Decompresses a ZIP file into a specified directory.

*@param*`inputFile` — - The path of the ZIP file to be decompressed.

*@param*`outputDirName` — - The name of the output directory.

*@returns* — A File path of the output directory.

```javascript
// Read a file
var filePath = "path/to/your/file.zip";
var file = FileUtil.readFile(filePath);
CompressionUtil.decompressZipFile(file, "uncompressedZipDirName");
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.b2winsuite.com/5.6/scripting/utilities/compressionutil.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
