unzip

Extracts the files of a zip archive.

Category: Programming > Files and Folders

Syntax

unzip(zipfilename)

Extracts into the current folder.

unzip(zipfilename, outputfolder)

Extracts into outputfolder, creating it if needed.

filenames = unzip(___)

Also returns the names of the extracted files.

Description

The paths stored in the archive are recreated below the output folder, and files with the same names are overwritten. unzip is the inverse of zip.

Input arguments

zipfilename
Name of the .zip file.
outputfolder
Destination folder.

Output arguments

filenames
Cell array with the names of the extracted files.

Example

Extracting to a folder

writelines('red', 'a.txt');
writelines('blue', 'b.txt');
zip('colors.zip', {'a.txt', 'b.txt'});
files = unzip('colors.zip', 'out');
numel(files)
isfile('out/b.txt')
Output
ans = 2
ans = logical
   1

Notes

In MatLivre the returned names are relative to the current folder (such as out\a.txt).

See also

zip untar gunzip tar