Extract or List Zip Archives

Extract files from or list a zip archive.

utilities, file
unzip(zipfile, files = NULL, list = FALSE, overwrite = TRUE, junkpaths = FALSE, exdir = ".", unzip = "internal", setTimes = FALSE)
The pathname of the zip file: tilde expansion (see path.expand) will be performed.
A character vector of recorded filepaths to be extracted: the default is to extract all files.
If TRUE, list the files and extract none. The equivalent of unzip -l.
If TRUE, overwrite existing files, otherwise ignore such files. The equivalent of unzip -o.
If TRUE, use only the basename of the stored filepath when extracting. The equivalent of unzip -j.
The directory to extract files to (the equivalent of unzip -d). It will be created if necessary.
The method to be used. An alternative is to use getOption("unzip"), which on a Unix-alike may be set to the path to a unzip program.
logical. For the internal method only, should the file time be set based on the times in the zip file? (NB: this applies to files, not to directories.

If list = TRUE, a data frame with columns Name (character) Length (the size of the uncompressed file, numeric) and Date (of class "POSIXct").Otherwise for the "internal" method, a character vector of the filepaths extracted to, invisibly.


The default internal method is a minimal implementation, principally designed for Windows' users to be able to unpack Windows binary packages without external software. It does not (for example) support Unicode filenames as introduced in zip 3.0: for that use unzip = "unzip" with unzip 6.00 or later. (It does have support for files of more than 4GB and bzip2 compression.)

If unzip specifies a program, the format of the dates listed with list = TRUE is unknown (on Windows it can even depend on the current locale) and the return values could be NA or expressed in the wrong time zone or misinterpreted (the latter being far less likely as from unzip 6.00).

File times in zip files are stored in the style of MS-DOS, as local times to an accuracy of 2 seconds. This is not very useful when transferring zip files between machines (even across continents), so we chose not to restore them by default.


The internal C code uses zlib and is in particular based on the contributed minizip application in the zlib sources (from http://zlib.net) by Gilles Vollant.

See Also

unz to read a single component from a zip file.


  • unzip
Documentation reproduced from package utils, version 3.1.2, License: Part of R 3.1.2

Community examples

ananduraj32@gmail.com at Jul 30, 2020 utils v3.6.2

## unzip() unzip the file named "file_to_be_unzipped" to the current working directory ```r unzip(zipfile = "file_to_be_unzipped", exdir = getwd()) ```