### 36.3 File Archiving Utilities

Function File: filelist = bunzip2 (bzfile)
Function File: filelist = bunzip2 (bzfile, dir)

  Unpack the bzip2 archive bzfile.

  If dir is specified the files are unpacked in this directory rather than the one where bzfile is located.

  The optional output filelist is a list of the uncompressed files.

  See also: bzip2, unpack, gunzip, unzip, untar.

Function File: filelist = gzip (files)
Function File: filelist = gzip (files, dir)

  Compress the list of files and directories specified in files.

  files is a character array or cell array of strings. Shell wildcards in the filename such as ‘`*`’ or ‘`?`’ are accepted and expanded. Each file is compressed separately and a new file with a `".gz"` extension is created. The original files are not modified, but existing compressed files will be silently overwritten. If a directory is specified then `gzip` recursively compresses all files in the directory.

  If dir is defined the compressed files are placed in this directory, rather than the original directory where the uncompressed file resides. If dir does not exist it is created.

  The optional output filelist is a list of the compressed files.

  See also: gunzip, unpack, bzip2, zip, tar.

Function File: filelist = gunzip (gzfile)
Function File: filelist = gunzip (gzfile, dir)

  Unpack the gzip archive gzfile.

  If gzfile is a directory, all gzfiles in the directory will be recursively unpacked.

  If dir is specified the files are unpacked in this directory rather than the one where gzfile is located.

  The optional output filelist is a list of the uncompressed files.

  See also: gzip, unpack, bunzip2, unzip, untar.

Function File: filelist = tar (tarfile, files)
Function File: filelist = tar (tarfile, files, rootdir)

  Pack the list of files and directories specified in files into the TAR archive tarfile.

  files is a character array or cell array of strings. Shell wildcards in the filename such as ‘`*`’ or ‘`?`’ are accepted and expanded. Directories are recursively traversed and all files are added to the archive.

  If rootdir is defined then any files without absolute pathnames are located relative to rootdir rather than the current directory.

  The optional output filelist is a list of the files that were included in the archive.

  See also: untar, unpack, bzip2, gzip, zip.

Function File: untar (tarfile)
Function File: untar (tarfile, dir)

  Unpack the TAR archive tarfile.

  If dir is specified the files are unpacked in this directory rather than the one where tarfile is located.

  The optional output filelist is a list of the uncompressed files.

  See also: tar, unpack, bunzip2, gunzip, unzip.

Function File: filelist = zip (zipfile, files)
Function File: filelist = zip (zipfile, files, rootdir)

  Compress the list of files and directories specified in files into the ZIP archive zipfile.

  files is a character array or cell array of strings. Shell wildcards in the filename such as ‘`*`’ or ‘`?`’ are accepted and expanded. Directories are recursively traversed and all files are compressed and added to the archive.

  If rootdir is defined then any files without absolute pathnames are located relative to rootdir rather than the current directory.

  The optional output filelist is a list of the files that were included in the archive.

  See also: unzip, unpack, bzip2, gzip, tar.

Function File: filelist = unzip (zipfile)
Function File: filelist = unzip (zipfile, dir)

  Unpack the ZIP archive zipfile.

  If dir is specified the files are unpacked in this directory rather than the one where zipfile is located.

  The optional output filelist is a list of the uncompressed files.

  See also: zip, unpack, bunzip2, gunzip, untar.

Function File: files = unpack (file)
Function File: files = unpack (file, dir)
Function File: files = unpack (file, dir, filetype)

  Unpack the archive file based on its extension to the directory dir.

  If file is a list of strings, then each file is unpacked individually. Shell wildcards in the filename such as ‘`*`’ or ‘`?`’ are accepted and expanded.

  If dir is not specified or is empty (`[]`), it defaults to the current directory. If a directory is in the file list, then filetype must also be specified.

  The specific archive filetype is inferred from the extension of the file. The filetype may also be specified directly using a string which corresponds to a known extension.

  Valid filetype extensions:

  `bz`
  `bz2`

    bzip archive

  `gz`

    gzip archive

  `tar`

    tar archive

  `tarbz`
  `tarbz2`
  `tbz`
  `tbz2`

    tar + bzip archive

  `targz`
  `tgz`

    tar + gzip archive

  `z`

    compress archive

  `zip`

    zip archive

  The optional return value is a list of files unpacked.

  See also: bunzip2, gunzip, unzip, untar, bzip2, gzip, zip, tar.

Function File: filelist = bzip2 (files)
Function File: filelist = bzip2 (files, dir)

  Compress the list of files specified in files.

  files is a character array or cell array of strings. Shell wildcards in the filename such as ‘`*`’ or ‘`?`’ are accepted and expanded. Each file is compressed separately and a new file with a `".bz2"` extension is created. The original files are not modified, but existing compressed files will be silently overwritten.

  If dir is defined the compressed files are placed in this directory, rather than the original directory where the uncompressed file resides. If dir does not exist it is created.

  The optional output filelist is a list of the compressed files.

  See also: bunzip2, unpack, gzip, zip, tar.