Topics   All   Mac OS X (Only)   Windows (Only)   Linux (Only, Not)   iOS (Only, Not)  
Components   Crossplatform Mac & Win   Server (Not)   Client   Old   Guides   Examples
New in version: 6.1   6.2   6.3   6.4   6.5   7.0   7.1   7.2   7.3   7.4    Statistic  

ZipFile.CompressFiles

Compresses a few files into a zip archive.

Component Version macOS Windows Server FileMaker Cloud FileMaker iOS SDK
Compression 6.0 Yes Yes Yes Yes Yes

MBS( "ZipFile.CompressFiles"; SourceFolder; ZipFilePath; FileList; Overwrite; CompressionLevel )

Parameters

Parameter Description Example value
SourceFolder The native file path to the source folder for files to compress. "/Users/cs/Desktop/test"
ZipFilePath The native file path to the zip archive. "/Users/cs/Desktop/test.zip"
FileList The list of relative file names to compress.
Please only ASCII file names.
"image1.jpg¶image2.jpg"
Overwrite Whether to overwrite the zip archive.
Pass 0 to not overwrite an existing file.
Pass 1 to overwrite.
Pass 2 to apend to a zip file.
1
CompressionLevel The compress level from 0 (no compression) to 9 (max compression).
Default is 9.
9

Result

Returns OK or error.

Description

Compresses a few files into a zip archive.
This is a simple function to compress a couple of files.
It does not preserve file permissions on Mac/Linux or other metadata.
And it may not work with non ASCII characters.

If you need more control over files being added, compression or error checking, please use example projects coming with plugin which use our other zip functions.

This function requires a native path. Use Path.FileMakerPathToNativePath to convert a FileMaker path to a native path if required. If you like to have the user choose the path, you can use FileDialog functions.
For Server be aware that server has limited permissions and may not be able to access all files on a computer.

Examples

Compresses some image files:

# first get list of file names in folder:
Set Variable [$list; Value:MBS( "Files.List"; "/Users/cs/Pictures/TestFiles")]
# now compress them:
Set Variable [$r; Value:MBS( "ZipFile.CompressFiles"; "/Users/cs/Pictures/TestFiles"; "/Users/cs/Desktop/test.zip"; $list; 0; 9 )]

Compress some images on Windows:

MBS( "ZipFile.CompressFiles"; "C:\Users\Administrator\Documents"; "C:\Users\Administrator\Desktop\test.zip"; "MBSLogo100.png¶test.png¶other.jpg"; 0; 9 )

See also


ZipFile.Close   -   ZipFile.CreateFile

Feedback: Report problem or ask question.




Links
MBS Xojo Plugins