ZipFile.CompressFiles
---------------------

Compresses a few files into a zip archive.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [Compression](component_Compression.md) | [6.0](newinversion60.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

### Deprecated

This function was [deprecated](deprecated.md). Use [Archive.Compress](ArchiveCompress.md) instead.

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

**MBS**( **"ZipFile.CompressFiles";** /\* Compresses a few files into a zip archive. \*/  
**$SourceFolder**; /\* The native file path to the source folder for files to compress.e.g. "/Users/cs/Desktop/test" \*/   
**$ZipFilePath**; /\* The native file path to the zip archive.e.g. "/Users/cs/Desktop/test.zip" \*/   
**$FileList**; /\* The list of relative file names to compress.  
Please only ASCII file names.e.g. "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.e.g. 1 \*/   
**$CompressionLevel**) /\* The compress level from 0 (no compression) to 9 (max compression).   
Default is 9.e.g. 9 \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| 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. We use UTF-8 on Mac/Linux/iOS, but there is no guarantee that this will work.  
  
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. Or use the [shell](component_Shell.md) functions and the zip command line tool.  
  
Deprecated due to missing unicode support. Please use [Archive.Compress](ArchiveCompress.md) for new projects.  
  
This function requires a native path. Use [Path.FileMakerPathToNativePath](PathFileMakerPathToNativePath.md) 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](component_FileDialog.md) 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](FilesList.md)"; "/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 )  
Zip a file on Mac:

 MBS ( "ZipFile.CompressFiles"; "/Users/cs/Desktop"; "/Users/cs/Desktop/Kontakte.zip"; "Kontakte.fmp12"; 1; 9 )  
Compress a folder on the desktop:

 Set Variable \[ $DesktopFolder ; Value: MBS ( "[Folders.UserDesktop](FoldersUserDesktop.md)" ) \]  
Set Variable \[ $Folder ; Value: MBS ( "[Path.AddPathComponent](PathAddPathComponent.md)"; $DesktopFolder ; "Island Fotos" ) \]  
Set Variable \[ $ZipPath ; Value: MBS ( "[Path.AddPathComponent](PathAddPathComponent.md)"; $DesktopFolder ; "Island Fotos.zip" ) \]  
Set Variable \[ $list ; Value: MBS ("[Files.List](FilesList.md)"; $Folder ) \]  
Set Variable \[ $r ; Value: MBS ( "ZipFile.CompressFiles"; $folder ; $ZipPath ; $list ; 1; 9 ) \]  
### See also

- [Archive.Compress](ArchiveCompress.md)
- [Files.List](FilesList.md)
- [Folders.UserDesktop](FoldersUserDesktop.md)
- [Path.AddPathComponent](PathAddPathComponent.md)
- [Path.FileMakerPathToNativePath](PathFileMakerPathToNativePath.md)

### Release notes

- **Version 15.5**
    - Fixed a problem on Windows with [ZipFile.CompressFiles](https://www.mbsplugins.eu/ZipFileCompressFiles.shtml) function not working.

### Blog Entries

- [MBS FileMaker Plugin, version 15.5pr1](https://www.mbsplugins.de/archive/2025-10-01/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [Comparing Base Elements Plugin to MBS FileMaker Plugin](https://www.mbsplugins.de/archive/2017-10-24/Comparing_Base_Elements_Plugin/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 6.1pr4](https://www.mbsplugins.de/archive/2016-03-03/MBS_FileMaker_Plugin_version_6/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 6.1pr2](https://www.mbsplugins.de/archive/2016-02-10/MBS_FileMaker_Plugin_version_6/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin 6.0 for OS X/Windows](https://www.mbsplugins.de/archive/2016-01-28/MBS_FileMaker_Plugin_60_for_OS/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 6.0pr7](https://www.mbsplugins.de/archive/2016-01-20/MBS_FileMaker_Plugin_version_6/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 16th January 2016 , last changed 10th July 2025

  
[ZipFile.Close](ZipFileClose.md) - [ZipFile.CreateFile](ZipFileCreateFile.md)

[HTML Version](ZipFileCompressFiles.shtml)