Expands a ZIP file into the specified folder.
UnZip [ Select ; Result (error) ; Zip filePath ; Destination folderPath ; Don't create archive folder ; Overwrite Existing items ; Timeout ]
|Select entire contents||replaces the entire 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|
|Zip filePath||the path to the ZIP file to be unzipped|
|Destination folderPath||the path to the folder where the ZIP is going to be expanded|
|Don’t create archive folder||don’t create an extra top folder if there are multiple items at the top level of the ZIP file|
|Overwrite Existing items||overwrite existing items in the destination folder(s)|
|Timeout||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 unzipped|
|$$-43||fnfErr||source file not found|
|$$-48||dupFNErr||destination ZIP folder already exists|
Other errors may be returned.
Troi File Plug-in 9.0
FileMaker Pro 16 to 19
The UnZip step will create the complete (sub)folder structure of the ZIP. This may take a bit of time for large ZIP files.
WARNING only use the option “Overwrite Existing items” when you are sure you don’t overwrite something important. If you first want to see what is in the ZIP file you can use the TrFile_GetZipInfo function to get a list of items. Alternatively it might be better to extract the contents of the ZIP in an empty folder first, and then copy the extracted files from that folder.
UnZip [ Select ; $ErrorCode ; "D:\myZIP2016.zip" ; "C:\resultDir\" ]
This will uncompress the ZIP file myZIP2016.zip into the folder resultDir. For example these files and folders might be created on the disk:
C:\resultDir\my report\my report\extra data\
C:\resultDir\my report\my report\extra data\note.txt
We assume that in your FileMaker file the following fields are defined and filled with the paths to the source ZIP file and destination folder:
this::sourceZipPath may contain something like "MacHD:Users:kip:bigtext.zip" this::destOfUnZIP_Path may contain something like "MacHD:Users:destFolder"
This example will first set the variables from the paths stored in the two fields, and then expand the ZIP file. In a script add the following steps:
# Initialize: copy the fields into variables first: Set Variable [ $SourceZIPfilePath ; this::sourceZipPath ] Set Variable [ $DestinationFolder ; this::destOfUnZIP_Path ] # Now unZIP it: UnZip [ Select ; $ErrorCode ; $SourceZIPfilePath ; $DestinationFolder ; Overwrite Existing items ] # Return the resulting error code: Exit Script [ $ErrorCode ]
NOTE: in this example we have specified the option “Overwrite Existing items” . Only use this option if you want to allow that existing items in the destination folder can be overwritten.
Related script step