Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

gzip

Compress files into GNU zip files

Syntax

gzip(filenames)
gzip(filenames,outputfolder)
entrynames = gzip(___)

Description

example

gzip(filenames) compresses the contents of the specified files and folders into GNU zip files with the file extension .gz. gzip recursively compresses the content in folders. gzip places each output file to the same folder as the input file.

example

gzip(filenames,outputfolder) places the resulting GNU zip files into outputfolder. If outputfolder does not exist, MATLAB® creates it.

example

entrynames = gzip(___) returns a cell array of character vectors containing the relative path names of all resulting files. You can use this syntax with any of the input argument combinations in the previous syntaxes.

Examples

collapse all

Compress all files with a .m and .mlx extension in the current folder and store the results in the archive folder.

compressedfiles = gzip({'*.m','*.mlx'},'archive');
compressedfiles
compressedfiles = 1x1 cell array
    {'archive/CompressSelectFilesExample.mlx.gz'}

Create a GNU zip file of a folder including all subfolders, and store the relative paths in the file.

Create a folder myfolder containing a subfolder mysubfolder and the files membrane.m and logo.m.

mkdir myfolder;
movefile('membrane.m','myfolder');
movefile('logo.m','myfolder');
cd myfolder;
mkdir mysubfolder;
cd ..

Create a GNU zip file of the contents of myfolder, including all subfolders.

gzippedfiles = gzip('myfolder');

Input Arguments

collapse all

Names of files or folders to compress, specified as a character vector or a cell array of character vectors.

Files that are on the MATLAB path can include a partial path. Otherwise, files must include a path relative to the current folder or an absolute path.

Folders must include a path relative to the current folder or an absolute path. On UNIX® systems, folders also can start with ~/ or ~username/, which expands to the current user's home folder or the specified user's home folder, respectively. You can use the wildcard character * when specifying files or folders, except when relying on the MATLAB path to resolve a file name or partial path name.

Target folder for the compressed files, specified as a character vector.

See Also

| | | |

Introduced before R2006a

Was this topic helpful?