CreateArchive
CreateArchive[source]
creates a compressed archive in the current directory from source.
CreateArchive[source,path]
creates a compressed archive in the directory or file specified by path.
Details 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 ".zip", ".gz", ".tar.gz", ".bz2", ".tar.bz2", ".tbz", ".tbz2", ".tb2", ".tgz" and ".zst".
- The source specification can be any of the following:
-
File["source"] or "source" explicit file name or a directory URL["url"] or "url" HTTP, HTTPS or FTP URL {source1,source2,…} a list of files or directories <"file1"source1,"file2"source2,… > rename each file or directory to filen - By default, CreateArchive creates an archive in the current working directory given by 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 path specifies a directory, a suitable file name for the archive is automatically chosen.
- CreateArchive returns the full file name of the archive it created, and $Failed if it cannot be created.
- The following options can be given:
-
CompressionLevel Automatic the compression level to use CreateIntermediateDirectories True whether to create intermediate directories OverwriteTarget False whether to overwrite an existing archive - Possible settings for OverwriteTarget include:
-
False do not overwrite an existing file True overwrite an existing file "KeepBoth" keep the existing file, automatically choosing a name for the new file - CreateArchive with URL sources accepts the following URLDownload options:
-
Authentication None authentication information to send CookieFunction Automatic function to apply to each cookie received ConnectionSettings Automatic speed and other settings for the connection FollowRedirects True whether to follow HTTP redirects Interactive True whether to allow interactive authentication dialogs TimeConstraint Infinity time to wait for a response VerifySecurityCertificates True whether to verify SSL security certificates - CreateArchive does not delete the source files or directories.
Examples
open allclose allBasic Examples (3)
Scope (11)
Source (5)
Create a ZIP archive from a single file:
Create a ZIP archive from a directory:
Gather a list of files to archive:
Create a ZIP archive from the chosen files:
Specify names for each file or directory inside the archive:
Import the list of file names included in the ZIP file:
Create a ZIP archive using both remote and local files:
Path (3)
If no destination is specified, the archive is placed in the path given by Directory[]:
Specify an explicit destination directory:
Options (4)
CompressionLevel (1)
CreateIntermediateDirectories (2)
OverwriteTarget (1)
Create a GZIP compressed file:
Files are not overwritten by default:
Use OverwriteTargetTrue to overwrite existing files:
Applications (1)
Use SendMail to send a directory with maximal file compression:
Properties & Relations (1)
CreateArchive constructs an archive from files and directories already on the file system:
Export can be used to create an archive from expressions in the Wolfram Language:
Text
Wolfram Research (2010), CreateArchive, Wolfram Language function, https://reference.wolfram.com/language/ref/CreateArchive.html (updated 2020).
CMS
Wolfram Language. 2010. "CreateArchive." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2020. https://reference.wolfram.com/language/ref/CreateArchive.html.
APA
Wolfram Language. (2010). CreateArchive. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/CreateArchive.html