Archive.ExtractFile
-------------------

Extracts one file and returns as container.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [Archive](component_Archive.md) | [10.4](newinversion104.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "Archive.ExtractFile"; Archive; FilePath { ; Passphrase; New file name; Options } ) 

**MBS**( **"Archive.ExtractFile";** /\* Extracts one file and returns as container. \*/  
**$Archive**; /\* Either container with archive or native file path.e.g. "C:\\test\\test.zip" \*/   
**$FilePath**; /\* The path name of the file within the archive.  
Or since version 14.3 the index of the item starting with 0 for the first file.e.g. "test/test.jpg" \*/   
**$Passphrase**; /\* Optional; Password to use for the archive. \*/   
**$New file name**; /\* Optional; The new file name to use for container.  
Default is to use name of the item in the zip archive. \*/   
**$Options**) /\* Optional; The options to pass to reader.  
This is a comma-separated list of options. Option names can be prefixed with module name.e.g. "hdrcharset=cp1252" \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| Archive | Either container with archive or native file path. | "C:\\test\\test.zip" |  |
| FilePath | The path name of the file within the archive.   Or since version 14.3 the index of the item starting with 0 for the first file. | "test/test.jpg" |  |
| Passphrase | Password to use for the archive. |  | Optional |
| New file name | The new file name to use for container.   Default is to use name of the item in the zip archive. |  | Optional |
| Options | The options to pass to reader.   This is a comma-separated list of options. Option names can be prefixed with module name. | "hdrcharset=cp1252" | Optional      Added in version **14.3**. |

### Result

Returns container or error.

### Description

Extracts one file and returns as container.  
You may use [Archive.FileList](ArchiveFileList.md) to get a list of file names in the archive.  
  
For pure gz file without an archive, you can use [Archive.GZipDecompress](ArchiveGZipDecompress.md) function.  
### Examples

Extract one PDF file:

 Set Field \[ Contacts::Photo Container ; MBS ( "Archive.ExtractFile"; "/Users/cs/Desktop/Archiv.zip"; "test40.pdf") \]  
Show version number of MBS plugin in Mac container:

 # extract info file with metadata   
Set Variable \[ $InfoFile ; Value: MBS ( "Archive.ExtractFile"; Install Plugin Update if needed::Plugin File Mac; "MBS .fmplugin/Contents/Info.plist" ) \]   
\# get it as text   
Set Variable \[ $InfoText ; Value: MBS ( "[Container.GetText](ContainerGetText.md)"; $InfoFile ; "FILE") \]   
\# query version entry in XML   
Set Variable \[ $version ; Value: MBS ( "[XML.GetPathValue](XMLGetPathValue.md)"; $InfoText ; "plist.dict.string\[6\]") \]   
Show Custom Dialog \[ "Version of MBS Plugin" ; $version \]  
Extract Mac version number via RegEx:

 # extract info file with metadata   
Set Variable \[ $InfoFile ; Value: MBS ( "Archive.ExtractFile"; Install Plugin Update if needed::Plugin File Mac; "MBS .fmplugin/Contents/Info.plist" ) \]   
\# get version as text   
Set Variable \[ $version ; Value: MBS ( "[RegEx.Extract](RegExExtract.md)"; $infoText ; "&lt;key&gt;CFBundleVersion&lt;/key&gt;\\s\*&lt;string&gt;(.\*)&lt;/string&gt;"; "\\1"; "greedy, caseless" ) \]   
Show Custom Dialog \[ "MBS Version" ; $version \]  
Extract first file:

 MBS ( "Archive.ExtractFile"; "/Users/cs/Desktop/test.zip"; 0)  
Extract first file with password:

 MBS ( "Archive.ExtractFile"; "/Users/cs/Desktop/test.zip"; 0; "Hello"; "test.txt"; "hdrcharset=UTF-8")  
### See also

- [Archive.CompressText](ArchiveCompressText.md)
- [Archive.Extract](ArchiveExtract.md)
- [Archive.FileList](ArchiveFileList.md)
- [Archive.GZipDecompress](ArchiveGZipDecompress.md)
- [Container.GetText](ContainerGetText.md)
- [RegEx.Extract](RegExExtract.md)
- [XML.GetPathValue](XMLGetPathValue.md)

### Release notes

- **Version 14.3**
    - Added Options parameter for [Archive.Content](https://www.mbsplugins.eu/ArchiveContent.shtml), [Archive.Extract](https://www.mbsplugins.eu/ArchiveExtract.shtml), [Archive.ExtractFile](https://www.mbsplugins.eu/ArchiveExtractFile.shtml), [Archive.FileList](https://www.mbsplugins.eu/ArchiveFileList.shtml) and [Archive.GZipDecompress](https://www.mbsplugins.eu/ArchiveGZipDecompress.shtml) functions.
- **Version 10.4**
    - Added [Archive.ExtractFile](https://www.mbsplugins.eu/ArchiveExtractFile.shtml) function.

### Example Databases

- [Archives/Archives](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Archives/Archives.shtml#3ScriptAnchor_)
- [Utility functions/Install Plugin Update if needed](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Utility%20functions/Install%20Plugin%20Update%20if%20needed.shtml#7ScriptAnchor_)

### Blog Entries

- [MBS FileMaker Plugin, version 14.3pr7](https://www.mbsplugins.de/archive/2024-07-05/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [Query MBS Version from plugin in container](https://www.mbsplugins.de/archive/2021-04-19/Query_MBS_Version_from_plugin_/monkeybreadsoftware_blog_filemaker)
- [What is new in the MBS FileMaker Plugin Version 10.4](https://www.mbsplugins.de/archive/2020-09-22/What_is_new_in_the_MBS_FileMak/monkeybreadsoftware_blog_filemaker)
- [Neues MBS FileMaker Plugin 10.4](https://www.mbsplugins.de/archive/2020-09-15/Neues_MBS_FileMaker_Plugin_104/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin 10.4 - More than 6300 Functions In One Plugin](https://www.mbsplugins.de/archive/2020-09-15/MBS_FileMaker_Plugin_104_-_Mor/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 10.4pr9](https://www.mbsplugins.de/archive/2020-09-11/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)

### FileMaker Magazin

- [Ausgabe 4/2023, Seite 39](https://filemaker-magazin.de/neuigkeit/4233-Appetithappen-FMM_202304)

This function checks for a license.

Created 7th September 2020 , last changed 15th July 2025

  
[Archive.Extract](ArchiveExtract.md) - [Archive.FileList](ArchiveFileList.md)

[HTML Version](ArchiveExtractFile.shtml)