Archive.CompressContainer
-------------------------

Compresses one container into a new archive.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [Archive](component_Archive.md) | [11.1](newinversion111.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "Archive.CompressContainer"; Format; Filter; Destination; Container { ; Options; Password } ) 

**MBS**( **"Archive.CompressContainer";** /\* Compresses one container into a new archive. \*/  
**$Format**; /\* The format to use.  
Formats: ar, arbsd, argnu, arsvr4, bsdtar, cd9660, cpio, gnutar, iso, iso9660, mtree, mtree-classic, newc, odc, oldtar, pax, paxr, posix, raw, rpax, shar, shardump, ustar, v7tar, v7, warc, xar, zip.e.g. "zip" \*/   
**$Filter**; /\* The filter to use.  
For zip format can be store, bzip2, zstd or deflate.  
Filters: b64encode, bzip2, compress, grzip, gzip, lrzip, lz4, lzip, lzma, lzop, uuencode, xz, zstd.  
  
Not all filters can be combined with all formats.e.g. "deflate" \*/   
**$Destination**; /\* The native file path to the destination archive.  
Or file name for container.e.g. "C:\\test.zip" \*/   
**$Container**; /\* The container to compress.  
We take the file name from container. \*/   
**$Options**; /\* Optional; The options to pass to writer.  
This is a comma-separated list of options. Option names can be prefixed with module name.  
  
Sample options:   
compression-level=9  
zip:encryption=zipcrypt  
zip:encryption=aes128  
zip:encryption=aes256  
zip64  
gzip:compression-level=9  
hdrcharset=UTF-8e.g. "zip:encryption=zipcrypt" \*/   
**$Password**) /\* Optional; The passphrase to use for password protection.e.g. "secret" \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| Format | The format to use.   Formats: ar, arbsd, argnu, arsvr4, bsdtar, cd9660, cpio, gnutar, iso, iso9660, mtree, mtree-classic, newc, odc, oldtar, pax, paxr, posix, raw, rpax, shar, shardump, ustar, v7tar, v7, warc, xar, zip. | "zip" |  |
| Filter | The filter to use.   For zip format can be store, bzip2, zstd or deflate.   Filters: b64encode, bzip2, compress, grzip, gzip, lrzip, lz4, lzip, lzma, lzop, uuencode, xz, zstd.      Not all filters can be combined with all formats. | "deflate" |  |
| Destination | The native file path to the destination archive.   Or file name for container. | "C:\\test.zip" |  |
| Container | The container to compress.   We take the file name from container. |  |  |
| Options | The options to pass to writer.   This is a comma-separated list of options. Option names can be prefixed with module name.      Sample options:    compression-level=9   zip:encryption=zipcrypt   zip:encryption=aes128   zip:encryption=aes256   zip64   gzip:compression-level=9   hdrcharset=UTF-8 | "zip:encryption=zipcrypt" | Optional |
| Password | The passphrase to use for password protection. | "secret" | Optional |

### Result

Returns OK, container or error.

### Description

Compresses one container into a new archive.  
Supports various compression algorithms and encryption.  
### Examples

Compress a container:

 Set Field \[ MyFile::CompressedFile ; MBS ( "Archive.CompressContainer"; "zip"; "deflate"; ""; MyFile::SomeContainer ; "hdrcharset=UTF-8" ) \]  
Compress a container to a zip file:

 Set Variable \[ $r ; Value: MBS ( "Archive.CompressContainer"; "zip"; "deflate"; "/Users/cs/Desktop/Test.zip"; Anlagen::SomeContainer ; "hdrcharset=UTF-8" ) \]  
Compress to gz:

 Set Variable \[ $r ; Value: MBS ( "Archive.CompressContainer"; "zip"; "deflate"; "/Users/cs/Desktop/Anlagen.zip"; Anlagen::SomeContainer ; "gzip:compression-level=9" ) \]  
Compress to gzip:

 Set Variable \[ $r ; Value: MBS ( "Archive.CompressContainer"; "raw"; "gzip"; "/Users/cs/Desktop/test2.jpg.gz"; Contacts::Photo Container) \]  
Compress PDF and add to email:

 # get some PDF from a field   
Set Variable \[ $PDF ; Value: Reports::ReportContainer \]  
\# Compress it   
Set Variable \[ $CompressedPDF ; Value: MBS ( "Archive.CompressContainer"; "zip"; "deflate"; "report.zip"; $pdf ) \]  
\# now add to email   
Set Variable \[ $email ; Value: MBS ( "[SendMail.CreateEmail](SendMailCreateEmail.md)") \]  
Set Variable \[ $r ; Value: MBS ( "[SendMail.AddAttachmentContainer](SendMailAddAttachmentContainer.md)"; $Email ; $CompressedPDF ; "report.zip"; "application/zip" ) \]  
Set Variable \[ $r ; Value: MBS ( "[SendMail.SetPlainText](SendMailSetPlainText.md)"; $email ; "Dear " &amp; Contacts::FullName &amp; ¶ &amp; ¶ &amp; "Attached you find the report from " &amp; Get(CurrentDate ) &amp; ¶ &amp; ¶ &amp; "Greetings" &amp; ¶ &amp; "Your FileMaker Server") \]  
Compress with lzma with 7zip:

 MBS ( "Archive.CompressContainer"; "7zip"; "xz"; "/Users/cs/Desktop/test.7z"; $myContainer )  
### See also

- [Archive.Compress](ArchiveCompress.md)
- [SendMail.AddAttachmentContainer](SendMailAddAttachmentContainer.md)
- [SendMail.CreateEmail](SendMailCreateEmail.md)
- [SendMail.SetPlainText](SendMailSetPlainText.md)

### Release notes

- **Version 15.3**
    - Added bzip2 and zstd as filter for zip archives for [Archive.Compress](https://www.mbsplugins.eu/ArchiveCompress.shtml), [Archive.CompressContainer](https://www.mbsplugins.eu/ArchiveCompressContainer.shtml), [Archive.CompressText](https://www.mbsplugins.eu/ArchiveCompressText.shtml) and [Archive.Create](https://www.mbsplugins.eu/ArchiveCreate.shtml) functions.
- **Version 11.1**
    - Added [Archive.CompressContainer](https://www.mbsplugins.eu/ArchiveCompressContainer.shtml) function.

### Blog Entries

- [MBS FileMaker Plugin, version 15.3pr5](https://www.mbsplugins.de/archive/2025-07-01/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [Compress and Send](https://www.mbsplugins.de/archive/2024-07-06/Compress_and_Send/monkeybreadsoftware_blog_filemaker)
- [Store large texts as container fields](https://www.mbsplugins.de/archive/2024-06-13/Store_large_texts_as_container/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin 11.1](https://www.mbsplugins.de/archive/2021-03-16/MBS_FileMaker_Plugin_111/monkeybreadsoftware_blog_filemaker)
- [Neues MBS FileMaker Plugin 11.1](https://www.mbsplugins.de/archive/2021-03-09/Neues_MBS_FileMaker_Plugin_111/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin 11.1](https://www.mbsplugins.de/archive/2021-03-09/MBS_FileMaker_Plugin_111/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 11.1pr6](https://www.mbsplugins.de/archive/2021-02-24/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)

### FileMaker Magazin

- [Ausgabe 4/2023, Seite 38](https://filemaker-magazin.de/neuigkeit/4233-Appetithappen-FMM_202304)

This function checks for a license.

Created 22nd February 2021 , last changed 9th February 2026

  
[Archive.Compress](ArchiveCompress.md) - [Archive.CompressText](ArchiveCompressText.md)

[HTML Version](ArchiveCompressContainer.shtml)