({{, (RefLink[CreateArchive, paclet:ref/CreateArchive])[source] 
creates a compressed archive in the current directory from a file or directory specified by source.}, {, (RefLink[CreateArchive, paclet:ref/CreateArchive])[source,path]
creates a compressed archive in the directory or file specified by path.}})

OpenersNotesSection(Spacer1)Details and Options

(RefLink[CreateArchive, paclet:ref/CreateArchive]) infers the compression format from the file extension of the archive name. If no extension is given, (RefLink[CreateArchive, paclet:ref/CreateArchive]) uses ZIP compression.

Possible file extensions include ".zip", ".gz", ".tar.gz", ".bz2", ".tar.bz2", ".tbz", ".tbz2", ".tb2", and ".tgz".

(RefLink[CreateArchive, paclet:ref/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, (RefLink[CreateArchive, paclet:ref/CreateArchive]) automatically chooses a suitable file name for the archive.

(RefLink[CreateArchive, paclet:ref/CreateArchive]) returns the full file name of the archive it created, and (RefLink[$Failed, paclet:ref/$Failed]) if it cannot be created.

The file archive to be created must not already exist.

(RefLink[CreateArchive, paclet:ref/CreateArchive]) takes an option (RefLink[CreateIntermediateDirectories, paclet:ref/CreateIntermediateDirectories]) to specify whether intermediate directories should be created. The default setting is (RefLink[True, paclet:ref/True]).

(RefLink[CreateArchive, paclet:ref/CreateArchive]) does not delete the source file or directory.

(RefLink[CreateArchive, paclet:ref/CreateArchive])[(RefLink[File, paclet:ref/File])["source"]] and (RefLink[CreateArchive, paclet:ref/CreateArchive])["Source",(RefLink[File, paclet:ref/File])["path"]] are also supported.

OpenersPrimaryExamplesSection(Spacer1)Examples  (5)

OpenersExampleSection0(Spacer1)Basic Examples  (4)

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

CreateArchive[$InstallationDirectory<>"/Documentation/English/System/ExampleData/"]

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

CreateArchive[ $InstallationDirectory<>"/Documentation/English/System/ExampleData/" ,"examples.tar.gz" ]

Specify an explicit destination path:

CreateArchive[ $InstallationDirectory<>"/Documentation/English/System/ExampleData/" ,$UserBaseDirectory ]

Fully specify a destination path and file name:

CreateArchive[ $InstallationDirectory<>"/Documentation/English/System/ExampleData/" ,$UserBaseDirectory<> "/archive.tar.bz2"]

OpenersExampleSection1(Spacer1)Options  (1)

OpenersExampleSubsection0(Spacer1)CreateIntermediateDirectories  (1)

Prevent creation of intermediate directories to the destination path:

CreateArchive[ $UserBaseDirectory ,$RootDirectory <> "non/existent/archive.zip", CreateIntermediateDirectories->False]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[ExtractArchive, paclet:ref/ExtractArchive])  ▪  (RefLink[Compress, paclet:ref/Compress])  ▪  (RefLink[Import, paclet:ref/Import])  ▪  (RefLink[Export, paclet:ref/Export])  ▪  (RefLink[FileSystemMap, paclet:ref/FileSystemMap])  ▪  (RefLink[CopyDirectory, paclet:ref/CopyDirectory])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Importing and Exporting, paclet:guide/ImportingAndExporting])}, {▪(RefLinkPlain[Compression and Archive Formats, paclet:guide/CompressionAndArchiveFormats])}, {▪(RefLinkPlain[File Operations, paclet:guide/FileOperations])}})}})