Get information from a ZIP file.
TrFile_GetZipInfo ( switches ; sourceZipFilePath )
|switches||modifies the behavior of the function|
|sourceZipFilePath||the path to the ZIP file|
Switches can be empty or this:
|-ItemList||(default) return the list of files and folders in the ZIP file|
You can also add this switch:
|-SkipHiddenMacOSXItems||don’t list items which are in a __MACOSX folder in the ZIP|
macOS stores extra info and resource forks in these __MACOSX folders
You can also add one of these encoding switches (Windows only), which determine how the filenames in the ZIP file bytes are interpreted.
Data type returned
a list of files and folders in the ZIP file.
The result can also be an error code. Returned error codes can be:
|$$-43||fnfErr||ZIP file not found|
Troi File Plug-in 8.5
FileMaker Pro 16 to FileMaker Pro 2023
Each item is returned on a separate line: all items (including the last item) are followed by a return character.
Version 13.0 added the -Encoding=xxx switches (on Windows only). The filenames in the ZIP file will be interpreted according to this switch. This is useful if the ZIP was created using a non-standard filename encoding. On macOS the encoding switch is currently ignored.
Set Field [ $ZIP_Items ; TrFile_GetZipInfo ( "-ItemList" ; "D:\myZIP2016.zip" ) ]
This will list what is stored in the ZIP file. The result will be for example:
my report/extra data/
my report/extra data/note.txt
In this list you see that the folder “my report” contains 2 files and a subfolder “extra data”. Folders end with a slash and subfolders are also separated with a slash.
We assume that in your FileMaker file the following fields are defined and filled with a path to the source ZIP file:
this::ZIPsourcePath may contain something like "MacHD:Users:kip:bigtext.zip" this::ZIPlist the result will be stored here
This example will first set the variable from the path stored in the first field and then list the items of the ZIP file.
In a script add the following steps:
# Initialize: copy the field into a variable first: Set Variable [ $SourcePath ; this::ZIPsourcePath ] # Now get the item list : Set Variable [ $ItemList ; TrFile_GetZipInfo ( "-ItemList" ; $SourcePath ) ] If [ Left ( $ItemList ; 2 ) <> "$$" Set Field [ this::ZIPlist ; $ItemList ] Else Show Custom Dialog [ "An error occurred" ; "OK" ] Endif
Used in example file
Troi File Plug-in online help (overview)