CreateArchive

CreateArchive[source]
creates a compressed archive in the current directory from a file or directory specified by source.

CreateArchive[source, path]
creates a compressed archive in the directory or file specified by path.

Details and OptionsDetails and Options

  • CreateArchive infers the compression format from the file extension of the archive name. If no extension is given, CreateArchive uses ZIP compression.
  • Possible file extensions include , , , , , , , , and .
  • CreateArchive[source] creates an archive file in the current working directory.
  • The source as well as the destination path can be a relative or absolute directory or file specification.
  • Relative directory or file paths are taken to be relative to the current working directory.
  • If a destination directory is given, CreateArchive automatically chooses a suitable file name for the archive.
  • CreateArchive returns the full file name of the archive it created, and $Failed if it cannot be created.
  • The file archive to be created must not already exist.
  • CreateArchive takes an option CreateIntermediateDirectories to specify whether intermediate directories should be created. The default setting is True.
  • CreateArchive does not delete the source file or directory.

ExamplesExamplesopen allclose all

Basic Examples (4)Basic Examples (4)

Create a ZIP archive from the ExampleData directory and place it into the current directory:

In[1]:=
Click for copyable input
Out[1]=

Create a .tar.gz archive in the current directory:

In[1]:=
Click for copyable input
Out[1]=

Specify an explicit destination path:

In[1]:=
Click for copyable input
Out[1]=

Fully specify a destination path and file name:

In[1]:=
Click for copyable input
Out[1]=
New in 8
New to Mathematica? Find your learning path »
Have a question? Ask support »