Create a ZIP file, from the specified file or folder.
Create Zip [ Select ; Result (error) ; Source path ; Destination Zip file ; Timeout ]
|Select entire contents||replaces the contents of a field with the result. If not checked the result replaces the currently selected portion of the field|
|Result (error)||an error code|
|Source path||the path to the source file or folder to be zipped|
|Destination Zip file||the path to the new ZIP file to be created|
|Timeout||(optional) specify the timeout time in seconds (default = 20 seconds)|
Data type returned
The returned result is an error code. An error always starts with 2 dollars, followed by the error code. You should always check for errors. Returned error codes can be:
|0||no error||The ZIP file was created|
|$$-43||fnfErr||Source file not found|
|$$-48||dupFNErr||Destination ZIP file already exists|
|$$-4230||timeoutErr||The creation of the ZIP timed out|
Other errors may be returned.
Troi File Plug-in 9.0
FileMaker Pro 16 to 19
You can zip a single file or a complete folder, including subfolders and all items contained in the folder.
Zipping many items can take a long time. With the Timeout option you can increase the timeout time so it is long enough.
Create Zip [ Select ; $ErrorCode ; "C:\dataDir\" ; "D:\myZIP2017.zip" ]
This will create a compressed ZIP file archive myZIP2017.zip with the contents of the folder dataDir.
We assume that in your FileMaker file the following fields are defined and filled with the paths to the source and destination ZIP file:
this::sourcePath may contain something like "MacHD:Users:kip:bigtext.doc" this::destinationZIPPath may contain something like "MacHD:Users:kip:bigtext.zip"
This example will first set the variables from the paths stored in the two fields, and then create the ZIP file.
In a script add the following steps:
# Initialize: copy the fields into variables first: Set Variable [ $SourcePath ; this::sourcePath ] Set Variable [ $DestinationZIP ; this::destinationZIPPath ] # # Now zip it: CreateZip [ Select ; $ErrorCode ; $SourcePath ; $DestinationZIP ; Timeout: 60 ]
This will create the zip file. If the step takes longer than 60 seconds the step is aborted and the plug-in will return with a timeout error $$-4230.
Related script steps