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.

unzip

Extract contents of zip file

Syntax

unzip(zipfilename)
unzip(zipfilename,outputfolder)
filenames = unzip(___)

Description

example

unzip(zipfilename) extracts the archived contents of zipfilename into the current folder, preserving the attributes and timestamps of each file. unzip can extract files from your local system or from an Internet URL.

If a file exists with the same name and the file is not read-only, MATLAB® overwrites it. Otherwise, MATLAB issues a warning. On Microsoft® Windows® platforms, the hidden, system, and archive attributes are not set.

example

unzip(zipfilename,outputfolder) extracts zipfilename into outputfolder. If outputfolder does not exist, MATLAB creates it.

example

filenames = unzip(___) returns a cell array of character vectors containing the names of the extracted files.

Examples

collapse all

Create a zip file and extract it to the folder archive.

Create the zip file examples.zip containing example MAT-files.

zip('examples.zip','*.mat',...
    fullfile(matlabroot,'toolbox','matlab','demos'))

Extract examples.zip to the folder archive.

exampleFiles = unzip('examples','archive')
exampleFiles = 1x40 cell array
  Columns 1 through 3

    {'archive/accide...'}    {'archive/airfoi...'}    {'archive/airlin...'}

  Columns 4 through 6

    {'archive/cape.mat'}    {'archive/census...'}    {'archive/clown.mat'}

  Columns 7 through 9

    {'archive/detail...'}    {'archive/dmbann...'}    {'archive/durer.mat'}

  Columns 10 through 12

    {'archive/earth.mat'}    {'archive/fatali...'}    {'archive/fluidt...'}

  Columns 13 through 15

    {'archive/flujet...'}    {'archive/gatlin...'}    {'archive/gatlin...'}

  Columns 16 through 18

    {'archive/intege...'}    {'archive/logo.mat'}    {'archive/mandri...'}

  Columns 19 through 21

    {'archive/mapred...'}    {'archive/membra...'}    {'archive/mri.mat'}

  Columns 22 through 24

    {'archive/patien...'}    {'archive/penny.mat'}    {'archive/quake.mat'}

  Columns 25 through 27

    {'archive/seamou...'}    {'archive/spine.mat'}    {'archive/stocks...'}

  Columns 28 through 30

    {'archive/tetmes...'}    {'archive/topo.mat'}    {'archive/topogr...'}

  Columns 31 through 33

    {'archive/trimes...'}    {'archive/trimes...'}    {'archive/truss.mat'}

  Columns 34 through 36

    {'archive/usapol...'}    {'archive/usasta...'}    {'archive/usbord...'}

  Columns 37 through 39

    {'archive/vibesd...'}    {'archive/west04...'}    {'archive/wind.mat'}

  Column 40

    {'archive/xpmndr...'}

Download and extract a zip file from a URL to a local folder.

Suppose you have the zip file example.zip stored at the URL http://example.com/example.zip. Download and extract the file to the example folder.

url = 'http://example.com/example.zip';
unzip(url);

Input Arguments

collapse all

Name of zip file to extract from, specified as a character vector. If zipfilename has no extension, MATLAB searches for zipfilename appended with .zip.

zipfilename must include a path relative to the current folder or an absolute path.

If zipfilename is a URL, zipfilename 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.

zipfilename must be smaller than 4 GB and be unencrypted. unzip does not support password-protected or encrypted zip archives.

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

Tips

  • To extract a zip file that contains non-7-bit ASCII characters, extract the file on a machine that has the appropriate language/encoding settings.

Introduced before R2006a

Was this topic helpful?