Code covered by the BSD License  

Highlights from
gipper: zip selected files, or exclude selected files

2.66667

2.7 | 3 ratings Rate this file 3 Downloads (last 30 days) File Size: 3.62 KB File ID: #15003

gipper: zip selected files, or exclude selected files

by Tim Davis

 

15 May 2007 (Updated 26 Nov 2007)

Creates a zip file, using regexp to include and/or exclude filenames that match a list of patterns

| Watch this File

File Information
Description

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' })

MATLAB release MATLAB 7.5 (R2007b)
Other requirements MATLAB 6.5 or greater.
Tags for This File  
Everyone's Tags
files, grep, path, regexp, utilities, zip
Tags I've Applied
Add New Tags Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (4)
17 Dec 2007 John McGowan  
21 May 2007 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."

16 May 2007 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

16 May 2007 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
18 May 2007

Added check to see if the gipper is properly installed.

26 Nov 2007

trivial change to H1 help line and example

Contact us