Topics
All
MacOS
(Only)
Windows
(Only)
Linux
(Only, Not)
iOS
(Only, Not)
Components
Crossplatform Mac & Win
Server
Client
Old
Deprecated
Guides
Examples
Videos
New in version:
11.4
11.5
12.0
12.1
12.2
12.3
12.4
12.5
13.0
13.1
Statistic
FMM
Blog
Archive.Create
Creates a new archive.
Component | Version | macOS | Windows | Linux | Server | iOS SDK |
Archive | 13.1 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |
Parameters
Parameter | Description | Example | Flags |
---|---|---|---|
Format | The format to use. Formats: 7zip, 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 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 destinaton archive. Or empty for container. |
"C:\test.zip" | Optional |
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 or error.
Description
Creates a new archive.You may call Archive.AddContainer, Archive.AddFile and Archive.AddText to add files and later call Archive.Close function to finish.
Supports various compression algorithms and encryption.
The archive usually should not contain the absolute paths of the files, so we need a base path and relative to that base path the list of files and folders to zip.
Examples
Create a zip file on desktop:
Set Variable [ $r ; Value: MBS( "Archive.Create"; "zip"; "deflate"; "/Users/cs/Desktop/test.zip") ]
# add a file from desktop folder:
Set Variable [ $r ; Value: MBS( "Archive.AddFile"; "test.png"; "/Users/cs/Desktop") ]
# add a text file:
Set Variable [ $r ; Value: MBS( "Archive.AddText"; "Hello World!"; "UTF-8"; "test.txt") ]
# add something from container field:
Set Variable [ $r ; Value: MBS( "Archive.AddContainer"; Kontakte::Foto) ]
# and close file.
Set Variable [ $r ; Value: MBS( "Archive.Close") ]
Create a zip and store in container:
Set Variable [ $r ; Value: MBS( "Archive.Create"; "zip"; "deflate"; "test.zip") ]
# add file from desktop:
Set Variable [ $r ; Value: MBS( "Archive.AddFile"; "test.png"; "/Users/cs/Desktop") ]
# add a text file:
Set Variable [ $r ; Value: MBS( "Archive.AddText"; "Hello World!"; "UTF-8"; "test.txt") ]
# add a picture:
Set Variable [ $r ; Value: MBS( "Archive.AddContainer"; MyTable::MyPhoto) ]
# close and get the container value:
Set Variable [ $container ; Value: MBS( "Archive.Close") ]
# Store in a Field:
Set Field [ MyTable::MyZip ; $container ]
Commit Records/Requests [ With dialog: Off ]
Compress PDF containers into a zip file:
Set Variable [ $path ; Value: MBS( "Path.AddPathComponent"; MBS( "Folders.UserDesktop" ); "test.zip" ) ]
Set Variable [ $r ; Value: MBS( "Archive.Create"; "zip"; "deflate"; $path) ]
If [ MBS("IsError") ]
Show Custom Dialog [ "Failed to create zip archive." ; $r ]
Exit Script [ Text Result: ]
End If
#
Go to Record/Request/Page [ First ]
Set Variable [ $destPage ; Value: 1 ]
Loop
Set Variable [ $r ; Value: MBS( "Archive.AddContainer"; Merge PDFs::InputPDF) ]
Go to Record/Request/Page [ Next ; Exit after last: On ]
End Loop
Set Variable [ $r ; Value: MBS( "Archive.Close") ]
See also
- Archive.AddContainer
- Archive.AddFile
- Archive.AddText
- Archive.Close
- Folders.UserDesktop
- IsError
- Path.AddPathComponent
Release notes
- Version 13.1
- Added Archive.Create, Archive.AddContainer, Archive.AddFile, Archive.AddText and Archive.Close functions.
Example Databases
Blog Entries
This function checks for a paid license.
Created 13th February 2023, last changed 17th February 2023
