Home / Alt manpages / zipsplit(1)

  • zipsplit(1)
  • User command
  • linux

Split a ZIP Archive into Smaller Files with zipsplit

You will turn one ordinary ZIP archive into a numbered series of smaller ZIP files, preview the number of parts first, and check that each part can be read. This is useful when an archive must fit a size limit for transfer or storage.

The examples use ZipSplit 3.0 from the Ubuntu zip package, version 3.0-13ubuntu0.2 on this machine. The upstream utility dates from 2008, so check the installed help when moving these commands to another system. Allow about ten minutes, plus the time needed to copy the archive.

You need a readable ZIP file, enough free space for the output parts, and a destination directory that already exists. The commands below are unprivileged. Do not use sudo unless the input or destination is deliberately restricted to root.

1. Check the installed command

Confirm which executable will run and record its version. This is read-only:

$ command -v zipsplit
/usr/bin/zipsplit
$ zipsplit -v
This is ZipSplit 3.0 (July 5th 2008), by Info-ZIP.
...
ZipSplit 3.0 (July 5th 2008)
$ dpkg-query -W -f='${Package} ${Version}\n' zip
zip 3.0-13ubuntu0.2

The default maximum output size is only 36,000 bytes. That is small by modern standards, so pass -n explicitly rather than relying on the default:

$ zipsplit -h
Usage:  zipsplit [-tipqs] [-n size] [-r room] [-b path] zipfile
  -n   make zip files no larger than "size" (default = 36000)

Checkpoint

You have confirmed the binary and chosen a size in bytes that is below the limit you need to meet.

2. Inspect the source archive

Set variables to keep the examples readable. Replace the placeholders with real paths. The ls and unzip -l commands do not alter the archive.

$ archive="/path/to/archive.zip"
$ output="/path/to/split-output"
$ test -r "$archive" && echo "source is readable"
source is readable
$ unzip -l "$archive"
Archive:  /path/to/archive.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
      ...  ...        ...     ...
---------                     ----
      ...                     ... files

Create the output directory before splitting. zipsplit does not create missing path components:

$ mkdir -p -- "$output"
$ test -d "$output" && echo "destination exists"
destination exists

Safety boundary

Use a new, empty directory while learning the command. The generated names are based on the source archive name, such as archive1.zip. Check for existing files before a real run, because replacing useful output is an avoidable recovery problem:

$ find "$output" -maxdepth 1 -type f -print
# no output is the safest result

3. Preview the number of parts

Use -t with the target size. It reports the plan and does not create output files:

$ zipsplit -t -n 500000 "$archive"
3 zip files would be made (67% efficiency)

The count and efficiency depend on the archive. Efficiency is a planning figure, not a guarantee that every part will contain the same number of bytes. ZIP headers and the archive's file boundaries affect the result.

Choose -n in bytes, not megabytes. For a nominal 10 MiB ceiling, write 10485760. Leave a margin when the receiving system has a strict limit:

$ part_size=10000000
$ zipsplit -t -n "$part_size" "$archive"
N zip files would be made (N% efficiency)

Replace the placeholder output with the actual count. If the preview fails, do not proceed to creation. The usual first checks are the source path, read permission, free space, and whether the archive is an unsupported type.

4. Create the numbered ZIP files

Pass the destination with -b. Include a trailing slash when you mean a directory. With the variables above, the command creates names such as /path/to/split-output/archive1.zip:

$ zipsplit -n "$part_size" -b "$output/" "$archive"
3 zip files will be made (67% efficiency)
creating: /path/to/split-output/archive1.zip
creating: /path/to/split-output/archive2.zip
creating: /path/to/split-output/archive3.zip

The source archive is read, not removed. The operation is still state-changing because it writes new files. If you stop halfway, keep the incomplete parts separate from a completed set. To undo a successful run, remove only the generated files after checking their names with find; there is no zipsplit undo command.

Checkpoint

Wait for the final creating: line and a successful shell status before verifying the parts.

5. Verify every part

First list the generated files and check their sizes:

$ find "$output" -maxdepth 1 -type f -name '*.zip' -printf '%f %s bytes\n' | sort
archive1.zip 987654 bytes
archive2.zip 998765 bytes
archive3.zip 456789 bytes

The exact sizes will differ. Next ask unzip to test each archive without extracting it. The loop stops if any part is corrupt:

$ for part in "$output"/*.zip; do
>   echo "testing $part"
>   unzip -t "$part" || exit
> done
testing /path/to/split-output/archive1.zip
No errors detected in compressed data of ...
testing /path/to/split-output/archive2.zip
No errors detected in compressed data of ...

Compare the contents as well. Count the entries in the original and parts, remembering that a directory may appear as an entry:

$ unzip -Z1 "$archive" | sort > /tmp/original-files.txt
$ for part in "$output"/*.zip; do unzip -Z1 "$part"; done | sort > /tmp/split-files.txt
$ cmp -s /tmp/original-files.txt /tmp/split-files.txt && echo "file lists match"
file lists match

The temporary lists contain file names from the archive. Treat them as potentially sensitive and remove them when no longer needed. The ZIP parts themselves remain your deliverables.

6. Handle limits and useful options

A single archive entry must fit within the effective part limit. If it cannot, zipsplit reports that the entry is too big and exits non-zero. Increasing -n is the remedy; zipsplit cannot divide one entry across multiple output files.

-i adds a zipsplit.idx index and counts its size against the first output file. Use it when recipients need a small index of the split set, then verify that the index was created in the working directory or destination expected by your installed build.

-r reserves a number of bytes on the first disk, which is useful for a controlled removable-media workflow. -p pauses between output files, so it is suitable for manually changing media but awkward in automation. -s forces a sequential split even when that requires more files. Try these in a preview first:

$ zipsplit -t -s -n "$part_size" "$archive"
N zip files would be made (N% efficiency)
$ zipsplit -t -i -n "$part_size" "$archive"
N zip files would be made (N% efficiency)

Do not use -p in a non-interactive job unless you have designed for its prompts. This version also documents that archives larger than 2 GB and already split archives are not supported. Check the installed manpage before processing an archive near those boundaries.

Done means

  • The installed ZipSplit version and source archive were checked.
  • -t produced a plan using an explicit byte limit.
  • The destination existed and did not contain confusing old output.
  • Every generated part passed unzip -t.
  • The combined sorted file list matches the original archive.
  • The original ZIP remains intact, and any temporary manifest files are handled safely.