Get information from a ZIP file.
TrFile_GetZipInfo ( switches ; sourceZipFilePath )
|switches||modifies the behavior of the function|
|sourceZipFilePath||the path to the ZIP file|
The switches parameter currently has one possible value:
|-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
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 19
Each item is returned on a separate line: all items (including the last item) are followed by a return character.
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