To File
The To File component is a destination component that writes incoming data to a file or multiple files as needed. It serves to expand on the File Writer component with additional configurations and settings.
This adapter can be easily modified to add additional functionality or to fulfil extra requirements.
Running the Component
The below steps assume the correct user permissions are in place to read/write files.
STEP 1: Import the To File component
Using +COMPONENT, import the To File component.
STEP 2: Setup the component configurations in the component card
![]()
Bolded fields are required, otherwise default values defined in config.json are used:
Field | Description | Default Value |
|---|---|---|
Destination Directory | The directory where the output file(s) will be stored. The adapter will attempt to create it if it does not exist. | |
Output File Name Format | The name and extension of the output files. %Y (year), %m (month), %d (day), %H (hour), %M (minute), %S (second) and %f (millisecond), %i (unique ID YYYYMMDDhhmmss_XXXXX) |
|
Write Each Message To | Specifies whether each inbound message will have its own file. |
|
Escape 8-Bit Characters | Specifies whether to escape non-ASCII characters in outbound messages. Ex. "é" would be sent as "\XE9" (in Latin-1 or Windows-1252) or "\XC3\XA9" (in UTF-8). |
|
Use Temporary Files | Separate files configuration only - specifies whether to use temporary files while writing. When true, it will append ".tmp" to files currently being written until the component is done writing to them. It will only remove the .tmp extension when a new file is written in. |
|
Output File Encoding | The encoding used in the output file. List of available encodings is available when you click to change the encoding. |
|
Enable Debug Logs | Enable/disable logging of additional debug information. |
|
STEP 3: Start the component and verify the files from your destination directory
Start the component.
Once inbound messages are processed, check the defined destination directory to see your newly created file(s).
Example Configurations
Example 1 - If you want one file for all messages
If you want one file for all messages:
-
Set Write Each Message To to A single file
-
This will result in a single “output.txt“ file containing all messages.
![]()
The Output File Name Format will behave differently depending on what Write Each Message To is set to.
-
If Write Each Message To set to A single file will result in a single file “output.txt“ that all the incoming data will be written to.
- If file masks are included, they will be replaced with their respective timestamps so output_%M.txt will be output_45.txt and will contain all the messages of the 45th minute.
-
If Write Each Message To set to Separate files will result in multiple files “output.txt” “output(1).txt” and so on…
- If file masks are included, they will be replaced with their respective timestamps so every message that arrived at the 45th for example, will be named “output_45.txt” then “output_45(1).txt” and so on…
Example 2 - If you want one file for every message
If you want one file for every message:
-
Set Write Each Message To to Separate files
-
Using the default Output File Name Format, the timestamp will be updated with the current time, each time a message is written to the file.
![]()
-
This will result in individual files generated as output.txt, output(1).txt, output(2).txt and so on. Similarly, with a timestamp mask “output_%Y_%m_%d_%H_%M_%S.txt”, if two messages come in at the same time then the name of the files will be: “output_2024_12_30_16_45_55.txt” and “output_2024_12_30_16_45_55(1).txt”
Example 3 - If you want one file for all the messages that came in the same second/minute/hour/day/month/year
If you want one file for all the messages that came in the same second/minute/hour/day/month/year:
-
Set Write Each Message To to A single file
-
Messages will be written to files according to the Output File Name Format timestamp specified.
![]()
The Output File Name Format *is both the format of the outbound file names as well as can be used to determine when a new file is created.*
You can modify a mask as required, but the smallest unit will determine how often a new file is created/a rollover happens. This allows you to organize data by the second/minute/hour/day/month/year (or millisecond) it arrived in.
-
If 2 bits of data arrived at 2024/12/30 at 16:45:55, they will be written to the same file with the name “output_2024_12_30_16_45_55.txt”.
-
If another bit came a second later, it will create a new file “output_2024_12_30_16_45_56.txt” and so on.
It is very important to note that if you group messages by hour/day/month etc. You will have to move these files otherwise they will cause a conflict whenever a roll over happens.
To give an example, if messages came in at the first day of the month with this name format: Output_%d.txt you will get a file with Output_01.txt and on the next month on the first day, the same file will be generated. However, since the old file already exists, *the new data will be appended to the old file.*