ziptools — The Bits that Python's zipfile Module Forgot

ziptools is both an importable module package and a collection of command-line scripts that extend 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 dirs 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 (X), Windows, Linux, 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, grab the full ziptools package here (or browse its unzipped content here), and see its README for a first-level overview. 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, see genhtml's scripts here and here. And for details on importing and calling ziptools' tool instead, see its in-file 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.

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