Documentation

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.gziprecursively compresses the content in folders.gzipplaces each output file to the same folder as the input file.

example

gzip(filenames,outputfolder)places the resulting GNU zip files intooutputfolder. Ifoutputfolderdoes 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.mand.mlxextension in the current folder and store the results in thearchivefolder.

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 foldermyfoldercontaining a subfoldermysubfolderand the filesmembrane.mandlogo.m.

mkdirmyfolder; movefile('membrane.m','myfolder'); movefile('logo.m','myfolder'); cdmyfolder; mkdirmysubfolder; cd..

Create a GNU zip file of the contents ofmyfolder, 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?