Main Content


Extract contents of GNU zip file



gunzip(gzipfilenames) extracts the archived contents of each file in gzipfilenames to the folder containing gzipfilenames. gunzip does not delete the original GNU zip files.

gunzip recursively extracts the content in folders. gunzip can extract files from your local system or files from an Internet URL.


gunzip(gzipfilenames,outputfolder) extracts gzipfilenames into outputfolder. If outputfolder does not exist, MATLAB® creates it.


filenames = gunzip(___) 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.


collapse all

Use the gunzip function to extract all the GNU zip files in the current folder.

files = gunzip('*.gz')
files = 1x1 cell array

Download and extract an archive file from a URL to a local folder.

Suppose you have the archive file example.tar.gz stored at the URL Download and extract the file to the example folder.

url = '';
gunzip(url, 'example');

Input Arguments

collapse all

Names of the GNU zip files to extract from, specified as a character vector, a cell array of character vectors, or a string array. File names must include a path relative to the current folder or an absolute path.

If gzipfilenames is a URL, gzipfilenames must include the protocol type (for example, http://). MATLAB downloads the URL to the temporary folder on your system, and then it deletes the URL on cleanup.

Data Types: char | string

Target folder for the extracted files, specified as a character vector or a string scalar.

Data Types: char | string

Output Arguments

collapse all

Names of extracted files, returned as a cell array of character vectors. If outputfolder specifies a relative path, filenames contains the relative path. If outputfolder specifies an absolute path, filenames contains the absolute path.

Version History

Introduced before R2006a

See Also

| | | |