ziptools — The Bits that Python's zipfile Module Forgot

Meet ziptools, a free program and library that lets you create and extract zipfiles on all your devices, using tools not available in Python's built-ins.


ziptools is both an importable module package and a collection of command-line scripts that create and extract zipfiles. It extends Python's zipfile module with crucial missing functionality. Most notable among ziptools' enhancements:

Folders: ziptools adds entire folder trees to zipfiles automatically
Modtimes: ziptools propagates original modtimes for files, folders, and links
Cruft skips: ziptools can either include or skip system "cruft" files on request
Symlinks: ziptools copies or follows symlinks to files and folders on Unix and Windows
Long paths: ziptools supports long pathnames on Windows beyond its normal limits

ziptools is also portable—it can create and extract standard-conforming zipfiles on Mac OS, Windows, Linux, Android, and others, and can serve as your sole zip and unzip utility on all these platforms. Simply use the local Python 3.X or 2.X, or install one where needed; ziptools works on either Python.


To get started, fetch the full ziptools package here—or browse its unzipped content here—and see its README for usage examples and documentation. The package's main create and extract scripts also come with loads of in-program documentation, as does its importable module they use.

And yes, ziptools zipped itself like this:

/...test$ python3 ziptools/ ziptools -skipcruft
Zipping ['ziptools'] to
Cruft patterns: {'skip': ['.*', '[dD]esktop.ini', 'Thumbs.db', '~*', '$*', '*.py[co]'], 'keep': ['.htaccess']}
Adding folder ziptools
--Skipped cruft file ziptools/.DS_Store
Adding  file  ziptools/
Adding folder ziptools/__pycache__
--Skipped cruft file ziptools/__pycache__/__init__.cpython-35.pyc
--Skipped cruft file ziptools/__pycache__/zipcruft.cpython-35.pyc
Adding  file  ziptools/

If you had ziptools already installed, you could unzip its package like this (but use your local unzip tool the first time around):

/...code$ ziptools/ . 
Unzipping from to .
Extracted ziptools/
		=> ziptools
Extracted ziptools/
		=> ziptools/
Extracted ziptools/__pycache__/
		=> ziptools/__pycache__
Extracted ziptools/
		=> ziptools/

For another example, see the busy-but-complete screenshot. For examples of other programs that build ziptools command lines on the fly, search for ziptools in genhtml's scripts here and here. And for details on importing and calling ziptools' tools more directly, see its examples and docs.


ziptools is also included as a nested tool in the Mergeall content backup/mirror tool, because it was initially developed for testing that system. See its top-level test/ziptools folder if you've already fetched a Mergeall package. The version of ziptools included in Mergeall is that current when Mergeall was packaged, but may be out of date; the latest version is always here.

This program was last changed June 2017.

For more code examples, see the programs page.

[Home] Books Programs Blog Python Author Training Search Email ©M.Lutz