Text.AppendTextFile
-------------------

Appends a text file with the given text.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [Text](component_Text.md) | [2.8](newinversion28.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "Text.AppendTextFile"; Text; FilePath { ; Encoding } ) 

**MBS**( **"Text.AppendTextFile";** /\* Appends a text file with the given text. \*/  
**$Text**; /\* The text to save.e.g. "Hello World" \*/   
**$FilePath**; /\* The native file path. Something like "/Users/cs/desktop/test.txt" on Mac and "C:\\Programs\\Data\\test.txt" on Windows. Files without path end in the root directory on Mac.e.g. "test.txt" \*/   
**$Encoding**) /\* Optional; The text encoding for text parameter.   
Default is native.e.g. "UTF-8" \*/ 

(old name: String.AppendTextFile)

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| Text | The text to save. | "Hello World" |  |
| FilePath | The native file path. Something like "/Users/cs/desktop/test.txt" on Mac and "C:\\Programs\\Data\\test.txt" on Windows. Files without path end in the root directory on Mac. | "test.txt" |  |
| Encoding | The text encoding for text parameter.    Default is native.   Possible encoding names: ANSI, ISO-8859-1, Latin1, Mac, Native, UTF-8, DOS, Hex, Base64 or Windows. More listed in the [FAQ](https://www.monkeybreadsoftware.com/filemaker/faq.shtml). | "UTF-8" | Optional |

### Result

Returns "OK" or an error message.

### Description

Appends a text file with the given text.  
You have to decide which encoding to use (if not native). We support a few encodings, but we can add more if you need something special.  
  
If the file does not exist, it will be created. You can use this function for logging to a text file.  
  
Please use [Text.ReplaceNewLine](TextReplaceNewLine.md) to define which line endings the file has.  
  
This function requires a native path. Use [Path.FileMakerPathToNativePath](PathFileMakerPathToNativePath.md) to convert a FileMaker path to a native path if required. If you like to have the user choose the path, you can use [FileDialog](component_FileDialog.md) functions.  
For Server be aware that server has limited permissions and may not be able to access all files on a computer.  
### Examples

Write UTF-8 file with some text:

 MBS ("Text.AppendTextFile"; $Text ; $Path ; "utf8" )  
Write a test text file:

 MBS ("Text.AppendTextFile"; "Hello World. Some umlauts: äöü"; "/Users/cs/Desktop/testfile.txt"; "native")  
### See also

- [BinaryFile.Append](BinaryFileAppend.md)
- [FM.DataViewerContent](FMDataViewerContent.md)
- [FM.ExecuteSQL.LastErrorMessage](FMExecuteSQLLastErrorMessage.md)
- [FM.ExecuteSQL.LastSQL](FMExecuteSQLLastSQL.md)
- [HotKey.SetEvaluate](HotKeySetEvaluate.md)
- [Path.FileMakerPathToNativePath](PathFileMakerPathToNativePath.md)
- [Text.ReadTextFile](TextReadTextFile.md)
- [Text.ReplaceNewLine](TextReplaceNewLine.md)
- [Text.WriteTextFile](TextWriteTextFile.md)

### Release notes

- **Version 12.2**
    - Changed [Text.AppendTextFile](https://www.mbsplugins.eu/TextAppendTextFile.shtml), [Text.WriteToContainer](https://www.mbsplugins.eu/TextWriteToContainer.shtml) and [Text.WriteTextFile](https://www.mbsplugins.eu/TextWriteTextFile.shtml) to allow writing BOM character.

### Example Databases

- [Text functions/Logfile](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Text%20functions/Logfile.shtml#1ScriptAnchor_)

### Blog Entries

- [Filemaker: Export Text to File](https://www.mbsplugins.de/archive/2025-06-26/Filemaker_Export_Text_to_File/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 12.2pr1](https://www.mbsplugins.de/archive/2022-04-01/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [Watching for Errors with MBS Plugin](https://www.mbsplugins.de/archive/2021-03-18/Watching_for_Errors_with_MBS_P/monkeybreadsoftware_blog_filemaker)
- [FileMaker 18 File Script Steps vs. BinaryFile functions](https://www.mbsplugins.de/archive/2019-06-03/FileMaker_18_File_Script_Steps/monkeybreadsoftware_blog_filemaker)
- [Evaluate vs. Script Trigger](https://www.mbsplugins.de/archive/2016-03-04/Evaluate_vs_Script_Trigger/monkeybreadsoftware_blog_filemaker)
- [Filemaker: Export Text to File](https://www.mbsplugins.de/archive/2012-11-08/Filemaker_Export_Text_to_File/monkeybreadsoftware_blog_filemaker)
- [MBS Filemaker Plugin, version 2.8fc](https://www.mbsplugins.de/archive/2012-08-06/MBS_Filemaker_Plugin_version_2/monkeybreadsoftware_blog_filemaker)

This function is free to use.

Created 18th August 2014 , last changed 4th August 2023

  
[Text.AddLineNumbers](TextAddLineNumbers.md) - [Text.CapitalCase](TextCapitalCase.md)

[HTML Version](TextAppendTextFile.shtml)