---
name: "ziptool"
section: "1"
platform: "linux"
package: "libzip"
version: "1.11.4-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/ziptool"
---

# ziptool(1)

modify zip archives

## NAME

**ziptool** – modify zip archives

## SYNOPSIS

**ziptool** \[**-ceghnrst**\] \[**-l** *length*\] \[**-o** *offset*\] *zip-archive* **command** \[*command-args* *...*\] \[**command** \[*command-args* *...*\] ...\]

## DESCRIPTION

**ziptool** modifies the zip archive *zip-archive* according to the *commands* given.

Supported options:

- **-c**

  Check zip archive consistency when opening it.

- **-e**

  Error if archive already exists (only useful with **-n**).

- **-g**

  Guess file name encoding (for **stat** command).

- **-h**

  Display help.

- **-l** *length*

  Only read *length* bytes of archive. See also **-o**.

- **-n**

  Create archive if it doesn't exist. See also **-e**.

- **-o** *offset*

  Start reading input archive from *offset*. See also **-l**.

- **-r**

  Print raw file name encoding without translation (for **stat** command).

- **-s**

  Follow file name convention strictly (for **stat** command).

- **-t**

  Disregard current file contents, if any. *Note*: use this with care, it deletes all existing file contents when you modify the archive.

### Commands

For all commands below, the index is zero-based. In other words, the first entry in the zip archive has index 0.

Supported commands and arguments are:

- **add** *name* *content*

  Add file called *name* using the string *content* from the command line as data.

- **add\_dir** *name*

  Add directory *name*.

- **add\_file** *name* *file\_to\_add* *offset* *len*

  Add file *name* to archive, using *len* bytes from the file *file\_to\_add* as input data, starting at *offset*.

- **add\_from\_zip** *name* *archivename* *index* *offset* *len*

  Add file called *name* to archive using data from another zip archive *archivename* using the entry with index *index* and reading *len* bytes from *offset*.

- **cat** *index*

  Output file contents for entry *index* to stdout.

- **count\_extra** *index* *flags*

  Print the number of extra fields for archive entry *index* using *flags*.

- **count\_extra\_by\_id** *index* *extra\_id* *flags*

  Print number of extra fields of type *extra\_id* for archive entry *index* using *flags*.

- **delete** *index*

  Remove entry at *index* from zip archive.

- **delete\_extra** *index* *extra\_idx* *flags*

  Remove extra field number *extra\_idx* from archive entry *index* using *flags*.

- **delete\_extra\_by\_id** *index* *extra\_id* *extra\_index* *flags*

  Remove extra field number *extra\_index* of type *extra\_id* from archive entry *index* using *flags*.

- **get\_archive\_comment**

  Print archive comment.

- **get\_archive\_flag** *flag*

  Print state of archive flag *flag*.

- **get\_extra** *index* *extra\_index* *flags*

  Print extra field *extra\_index* for archive entry *index* using *flags*.

- **get\_extra\_by\_id** *index* *extra\_id* *extra\_index* *flags*

  Print extra field *extra\_index* of type *extra\_id* for archive entry *index* using *flags*.

- **get\_file\_comment** *index*

  Get file comment for archive entry *index*.

- **get\_num\_entries** *flags*

  Print number of entries in archive using *flags*.

- **name\_locate** *name* *flags*

  Find entry in archive with the filename *name* using *flags* and print its index.

- **rename** *index* *name*

  Rename archive entry *index* to *name*.

- **replace\_file\_contents** *index* *data*

  Replace file contents for archive entry *index* with the string *data*.

- **set\_archive\_comment** *comment*

  Set archive comment to *comment*.

- **get\_archive\_flag** *flag* *value*

  Set archive flag *flag* to *value*.

- **set\_extra** *index* *extra\_id* *extra\_index* *flags* *value*

  Set extra field number *extra\_index* of type *extra\_id* for archive entry *index* using *flags* to *value*.

- **set\_file\_comment** *index* *comment*

  Set file comment for archive entry *index* to string *comment*.

- **set\_file\_compression** *index* *method* *compression\_flags*

  Set file compression method for archive entry *index* to *method* using *compression\_flags*. *Note*: Currently, *compression\_flags* are ignored.

- **set\_file\_encryption** *index* *method* *password*

  Set file encryption method for archive entry *index* to *method* with password *password*.

- **set\_file\_mtime** *index* *timestamp*

  Set file modification time for archive entry *index* to UNIX mtime *timestamp*.

- **set\_file\_mtime\_all** *timestamp*

  Set file modification time for all archive entries to UNIX mtime *timestamp*.

- **set\_password** *password*

  Set default password for encryption/decryption to *password*.

- **stat** *index*

  Print information about archive entry *index*.

### Flags

Some commands take flag arguments. Each character in the argument sets the corresponding flag. Use 0 or the empty string for no flags.

Supported flags are:

- *4*

  ZIP\_FL\_ENC\_CP437

- *8*

  ZIP\_FL\_ENC\_UTF\_8

- *C*

  ZIP\_FL\_NOCASE

- *c*

  ZIP\_FL\_CENTRAL

- *d*

  ZIP\_FL\_NODIR

- *l*

  ZIP\_FL\_LOCAL

- *r*

  ZIP\_FL\_ENC\_RAW

- *s*

  ZIP\_FL\_ENC\_STRICT

- *u*

  ZIP\_FL\_UNCHANGED

### Archive flags

**get\_archive\_flag** and **set\_archive\_flag** work on the following flags:

- create-or-keep-empty-file-for-archive

- is-torrentzip

- rdonly

- want-torrentzip

### Compression Methods

Some commands take compression method arguments. Supported methods are:

- default

- deflate

- store

### Encryption Methods

Some commands take encryption method arguments. Supported methods are:

- none

- AES-128

- AES-192

- AES-256

## EXIT STATUS

The **ziptool** utility exits 0 on success, and \>0 if an error occurs.

## EXAMPLES

Add a file called *teststring.txt* to the zip archive *testbuffer.zip* with data “This is a test.\\n” where “\\n” is replaced with a newline character:

```
ziptool testbuffer.zip add teststring.txt \"This is a test.\n\"
```

Delete the first file from the zip archive *testfile.zip*:

```
ziptool testfile.zip delete 0
```

## SEE ALSO

[zipcmp(1)](/zipcmp/1.md), [zipmerge(1)](/zipmerge/1.md), [libzip(3)](/libzip/3.md)

## HISTORY

**ziptool** was added in libzip 1.1.

## AUTHORS

Dieter Baron ⟨*dillo@nih.at*⟩ and Thomas Klausner ⟨*wiz@gatalith.at*⟩
