.zip()

Method to zip a folder object using 7-Zip. In order to use this method, you need to have 7-Zip installed. The global variable v7Location must hold a valid path to the 7-Zip executable. When no path is specified, the function shows a dialog with which the user can point to the 7-Zip executable.

Note: This function zips the contents of the folder and not the folder itself.

The method .zip() is located in the file zip.jsxinc.

Usage

To zip a folder:

var folder = new Folder("C:/myfolder");
folder.zip('C:/myfolder/zip.zip');

Parameters

Parameter Data type Required Description
zipname String The name of the archive, including the extension.
method String   The zip method to use. Default is tzip.
compression String or Number   The compression to use. Default is false.
archivecommand String   The archive command to use. Default is a.

Return values

Value Meaning
true The folder has been zipped. Note: This method uses the command line to zip the file. For the command line this method uses the function ExecuteBatchFile(). The return value of this function is limited to the return value of the function ExecuteBatchFile().
false The folder could not be zipped.

Available values for parameters

This paragraph lists the values you can use for the parameters of the method .zip().

method

This paragraph lists the available methods for zipping the archive.

Method Meaning
tz7b 7z format
tgzip GZIP format
tzip ZIP format
tbzip2 BZIP2 format
tiso ISO format
tudf UDF format

compression

This paragraph lists the available compressions for zipping the archive.

Compression Meaning
0 No compression.
1 Very low compression.
3 Fast compression.
5 Normal compression.
7 High compression.
9 Ultra compression.
false Use default compression

archivecommand

This paragraph lists the available archive commands.

Command Meaning
a Add file to archive.
u Update file in archive.