36.3 File Archiving Utilities

 
: bunzip2 (bzfile)
: bunzip2 (bzfile, dir)
: filelist = bunzip2 (…)

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.

 
: filelist = gzip (files)
: 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. Note that this does not replicate a directory tree in dir which may lead to files overwriting each other if there are multiple files with the same name.

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.

 
: gunzip (gzfile)
: gunzip (gzfile, outdir)
: filelist = gunzip (…)

Unpack the gzip archive gzfile.

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

If outdir 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.

 
: filelist = tar (tarfile, files)
: 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.

 
: untar (tarfile)
: untar (tarfile, dir)
: filelist = untar (…)

Unpack the TAR archive tarfile.

If dir is specified the files are unpacked in this directory rather than the current directory.

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

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

 
: filelist = zip (zipfile, files)
: 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.

 
: unzip (zipfile)
: unzip (zipfile, dir)
: filelist = unzip (…)

Unpack the ZIP archive zipfile.

If dir is specified the files are unpacked in this directory rather than the current directory.

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

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

 
: files = unpack (file)
: files = unpack (file, dir)
: 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.

 
: filelist = bzip2 (files)
: 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. Note that this does not replicate a directory tree in dir which may lead to files overwriting each other if there are multiple files with the same name.

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.