ZIPTOOL(1)

πŸ“¦
version 1.11.4 Β· 3 versions
, in arch rolling, debian trixie, fedora 43, fedora 44, nixpkgs unstable, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– ZIPTOOL(1) πŸ’–

hey bestie!! so this is the manual page for ziptool β€” it lives in the General Commands Manual section, and it is literally the little gadget that lets you poke at a zip archive from the command line. buckle up, it's giving ✨chaos goblin✨ in the best way πŸŽ€


✨ NAME ✨

ziptool β€” modify zip archives. that's it, that's the whole job. she modifies zips. πŸ’…


🌸 SYNOPSIS 🌸

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

okay so it's the flags, then your zip-archive, then one or more commands, each one optionally followed by its own little pile of arguments. stack 'em up, bestie 🫢


πŸ¦‹ DESCRIPTION πŸ¦‹

ziptool modifies the zip archive zip-archive according to the commands given. no cap, that's the entire personality.

Supported options:

  • -c β€” Check zip archive consistency when opening it. πŸ”
  • -e β€” Error if archive already exists (only useful with -n). like, don't touch it if it's already there, tyvm.
  • -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.
⚠️ bestie listen to me: use -t with care β€” it deletes all existing file contents when you modify the archive. like, gone gone. 😭

πŸŽ€ Commands πŸŽ€

For all commands below, the index is zero-based. In other words, the first entry in the zip archive has index 0. yes, zero. the first one is zero. i don't make the rules, i just think they're iconic. πŸ’…

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. 🫢 stealing, but politely.
  • 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. πŸ™ˆ (she's just standing there. not being used. iconic.)
  • 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. ⏰ all of them. at once. slay.
  • 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. πŸ’€ zero flags, zero thoughts, head empty.

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
🌈 pspsps bestie: those are case-sensitive. C and c are two completely different girls. don't mix them up.

πŸ‘‘ 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. zero = we ate. anything else = we did not eat. 😌


πŸ”₯ 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 that 0? first file. zero-based. i told you. 🫢


🌈 SEE ALSO 🌈


πŸ“œ HISTORY πŸ“œ

ziptool was added in libzip 1.1. a classic. a legend. a pioneer. ✨


πŸ’– AUTHORS πŸ’–

Dieter Baron <dillo@nih.at> and Thomas Klausner <wiz@gatalith.at> β€” the icons who built her πŸ‘‘


okay that's the whole page bestie, mwah πŸ’‹ this beauty shipped from Debian on January 23, 2023 β€” go forth and modify some zip archives, you absolute main character πŸŽ€πŸ¦‹πŸ’…

πŸ“¦ where this page comes from