Compress/extract files

Syntax1 - compress

zip zipfile files [flags] [warnings] [nozipext]

 

Syntax2 - extract

zip- zipfile folder [flags2] [warnings]

 

Parameters

zipfile - standard zip file.

files - file or folder to compress. Supports wildcard characters. Can also be list of files/folders. In the list, lines beginning with > character are skipped.

flags:

1 Minimal compression level (faster).
2 Store full paths.
4 Don't store relative paths when adding folder.
8 (QM 2.3.0) Add files but don't compress. Don't use together with flag 1.

warnings - str variable that receives list of errors ("file not found", etc). If used, files failed to add/extract are skipped. If not used or is 0, on failure is generated error.

nozipext - (QM 2.3.0) comma-separated list of filename extensions. Files of these types will be added but not compressed. Example: "mp3,rar,jpg,chm".

 

folder - folder where to extract files.

flags2 - combination of the following values. Default: 0.

1 Overwrite read-only files.

 

Remarks

Syntax1: Creates new zip file zipfile and adds files to it. If the specified zip file already exists, overwrites.

 

Syntax2: Extracts all files from zip file zipfile to the specified folder.

 

Zip file format does not support Unicode filenames within zip files. When QM runs in ANSI mode, Unicode characters are converted to similar ANSI characters or ?, and therefore the zip file may be invalid. To partially support Unicode, when QM runs in Unicode mode, it adds/extracts UTF-8 file names. Then the zip file is always valid, although other programs will not decode UTF-8. Generally you should not use Unicode filenames with zip.

 

Cannot create or extract zip files bigger than 2 GB.

 

Example

str zf="$desktop$\test.zip"
str sf.getmacro("List of files to zip")
str sw

out "zip"
zip zf sf 0 sw
if(sw.len) out sw

out "unzip"
zip- zf "$desktop$\unzip" 0 sw
if(sw.len) out sw