TrFile_CreateZip (function reference)

By May 1, 2017May 20th, 2020Online Help, Troi File Plug-in
Troi File Plug-in for FileMaker Pro


Create a ZIP file, from the specified file or folder.

SyntaxFunction badge

TrFile_CreateZip ( switches ; sourcePath ; destZipFile )


switches this alters the behavior of the function
sourcePath the path to the source file or folder to be zipped
destZipFile the path to the new ZIP file to be created


Switches can be empty or this:

-TimeoutSecs=x specify the timeout time in x seconds (default = 20 seconds)
-DontAddEnclosingFolder the top folder will not be added to the ZIP file, only the contents of the top folder.

Returned Result

Data type returned

Error code


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

Other errors may be returned.

Originated in

Troi File Plug-in 8.0


FileMaker Pro 15 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 “-TimeoutSecs=x” switch you can increase the timeout time so it is long enough.
v12.0 added the switch “-DontAddEnclosingFolder”


Set Field [ $ErrorCode ; TrFile_CreateZip ( "-Unused" ; "C:\dataDir\" ; "D:\" ) ]

This will create a compressed ZIP file archive with the contents of the folder dataDir.

Example 2

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 ""

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:
Set Variable [ $ErrorCode ; TrFile_CreateZip ( "-Unused" ; $SourcePath ; $DestinationZIP ) ]

Related functionsFunction badge


Related topics

Troi File Plug-in online help (overview)

Online Help Page for Troi File Plug-in for 15 to 19 –> TrFile_CreateZip (filep4303) 2020-0520 15:58:43