File Exchange

image thumbnail


version (7.24 KB) by Tim Davis
Creates a zip file, using regexp to include and/or exclude filenames that match a list of patterns

1 Download

Updated 20 Nov 2014

View License

GIPPER : zip selected files and subdirectories (gipper = grep + zip)

files = gipper (directory, include, exclude, exclude_hidden) ;

Creates a zip file of all files and subdirectories in a directory. A file in the directory or any of its subdirectories whose name matches any expression in 'include' via regexp is added to the zip file. A file that matches any expression in 'exclude' is not added. A subdirectory whose name or full pathname matches any expression in 'exclude' is not searched. The name of the zip file is the name of the directory, with '.zip' appended.

Hidden files are excluded by default.

Examples, assuming "X" is the name of the current directory:

% include all files in X (except hidden files) in the zip file ../


% create archive of the 'X/mytoolbox' directory

gipper mytoolbox

% only include *.m files in ../

gipper '' '\.m$'

% create ../, but exclude compiled object and MEX files

gipper ('', '', { '\.o$' '\.obj$', ['\.' mexext '$'] })

% include everything, including hidden files, in ../

gipper ('', '', '', 0)

% zip mytoolbox, except hidden files and the mytoolbox/old directory

gipper mytoolbox '' old

% these are the same, except gipper also traverses subdirectories

gipper ('', { '\.m$', '\.*mat$' })
zip ('../X', { '*.m', '*.mat' })

Cite As

Tim Davis (2020). gipper (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (4)

John McGowan

Tim Davis

Regarding the inscrutable error mentioned below. This is because the directory containing gipper.m was not in your MATLAB path. It was simply not found by MATLAB. The gipper cd's to the parent if it needs to create a zip file of the current directory (if it didn't, the zip file would contain odd paths in its contents). After doing "cd ..", it calls itself recursively ... but if the directory containing gipper.m is not in your path, this fails. I added a test for this, and an error "To install the gipper, type 'pathtool' and add the directory in which it resides."

Urs (us) Schwarz

tim, several of your examples (when copy/pasted into the command window of a winvista/r2007a) yield an inscrutable error, eg,
- gipper ('', '', '', 0)
- gipper '' '\.m$'
??? Undefined function or method 'gipper' for input arguments of type 'cell'.

John D'Errico

The gipper is a must have, absolutely so if you have a Mac and you upload .zip files to the FEX. It automatically excludes any hidden files from the zip. My thanks to Tim for writing this.


Fix for filesep.

trivial change to H1 help line and example

Added check to see if the gipper is properly installed.

MATLAB Release Compatibility
Created with R2007b
Compatible with any release
Platform Compatibility
Windows macOS Linux