File Exchange

image thumbnail

gipper

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

0 Downloads

Updated 20 Nov 2014

View License

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

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 ../X.zip

gipper

% create mytoolbox.zip archive of the 'X/mytoolbox' directory

gipper mytoolbox

% only include *.m files in ../X.zip

gipper '' '\.m$'

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

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

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

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 (2019). gipper (https://www.mathworks.com/matlabcentral/fileexchange/15003-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'.
us

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.

Updates

1.1.0.0

Fix for filesep.

1.0.0.0

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