zip()

Read(114) Label: zip, compression, decompression,

Description:
 
Perform file compression operations.

Syntax:
 
zip(
zipfile:encoding,passowrd; path, files)

Note:

The function performs various file compression operations.

Options:

@u

Decompression

@a

Append a new compressed file to an existing compressed file

@d

Delete a file in a compressed file

@n

Won’t perform recursive compression over subdirectories, only compress files of the current level

@f

List files in a compressed file

@p

List directories in a compressed file

Parameters:

zipfile

A compressed file

encoding

Charset; default is utf-8

password

A password; can be absent

path

The root directory holding a to-be-compressed file; it is the directory holding zipfile when the parameter is null or absent. The comma (“,”) after the parameter should be retained even the parameter is absent

files

A file or a sequence of files. Wildcard characters * and ? are allowed in a file name; the former represents any string and the latter represents a single character. With wildcard characters and if the name of the directory where the to-be-compressed file(s) are located isn’t the same with that of the directory holding the future compressed file(s), then the function will also compressed the directory, which contains the absolute path. In that case, the directory list generated via @p option is empty

 

Return value:
Return a Boolean value for compression, appending or deletion, or a file list for other operations

Example:

 

A

 

1

=zip("D:/z1.zip":"GBK","123";,"D:/testData/f1/")

Compress all files under D:/testData/f1/ directory into z1.zip with charset GBK; password for the compressed file is 123; placeholder “,” remains though parameter path is absent

2

=zip("D:/z2.zip";,"D:/testData/f1/")

Compress all files under D:/testData/f1/ directory into z2.zip with default charset utf-8; no password for the compressed file

3

=zip("D:/z4.zip";"D:/testData/f1","/*")

Compress all files under D:/testData/f1/ directory into z4.zip; the resulting file is the same as A2

4

=zip("D:/z5.zip";"D:/testData/f1/")

Compress all files under D:/testData/f1/ directory into z5.zip; with parameter files being absent, the resulting file is the same as A2

5

=zip("D:/z6.zip";,"D:/testData/f1/?ity.txt")

Compress files under D:/testData/f1/ directory whose names matching ?ity.txt with wildcard character ? into z6.zip

6

=zip("D:/z7.zip";,"D:/testData/f1/*.txt")

Compress files under D:/testData/f1/ directory whose names matching *.txt with wildcard character * into z7.zip

7

=["f2/*.txt","f2/*.csv","f2/*.xls"]

 

8

=zip("D:/z8.zip";"D:/testData/",A7)

Parameter files is a sequence, so compress text, csv and xls files under D:/testData/f2/ directory into z8.zip

9

=zip("D:/ZipTest/z11.zip";"testData/f1/")

Parameter path is a relative path, which is relative to the path parameter zipfile specifies; this compresses files under D:/ZipTest/testData/f1/into z11.zip

10

=zip@u("D:/z1.zip":"GBK","123";"D:/zfu/z1")

Decompress z1.zip into D:/zfu/z1 directory with password 123

11

=zip@a("D:/z2.zip";,"D:/testData/f_a/")

Append files under D:/testData/f_a/ directory to z2.zip

12

=zip@d("D:/z2.zip";"f1","C*.txt")

Delete files whose names match C*.txt under f1 directory from z2.zip

13

=zip@n("D:/z13.zip";,"D:/testData/")

Compress files under D:/testData/ into z13.zip; with @u option, the function doesn’t perform a recursion, which means files under subdirectories won’t be compressed

14

=zip@f("D:/z1.zip")

List files under a compressed file without a password

15

=zip@p("D:/z2.zip")

List directories in a compressed file

16

=zip@p("D:/z7.zip")

With a wild character and since the location of the to-be-compressed file isn’t the one holding the would-be compressed file z7.zip, the list of multilevel directories generated via @p option is empty

17

=zip("D:/testData/z15.zip";,"D:/testData/f1/*")

Since a wildcard character is used and the path containing the to-be-compressed file is the same one holding the would-be compressed file, the result file won’t contain a multilevel directory

18

//=zip@p("D:/testData/z15.zip")

With @p option, the function lists the directory

19

=zip("D:/z14.zip";,"D:/testData/")

Compress the file by recursively looping over subdirectories and get a compressed file containing multilevel directories

20

=zip@p("D:/z14.zip")

List multilevel directories