Write File
Writes a text content to the specified file path
Common Properties
- Name - The custom name of the node.
- Color - The custom color of the node.
- Delay Before (sec) - Waits in seconds before executing the node.
- Delay After (sec) - Waits in seconds after executing node.
- Continue On Error - Automation will continue regardless of any error. The default value is false.
info
if ContinueOnError property is true, no error is caught when the project is executed even if Catch node is used.
Input
- Path - The path of the file that will be write to it.
- Text - The text for writing to the specified file.
Options
- Write Mode - Type for writing the file Append for appending the content to an existing file, Truncate for overwriting the content if the file exists.
- Base64 - Converts the provided base64 text content into binary format while writing the data.
How It Works
The Write File node saves content to files through the following process:
- Validates that the file path is not empty
- Validates that the write mode is either "append" or "truncate"
- If Base64 option is enabled:
- Decodes the base64 string to binary data
- If Base64 option is disabled:
- Uses the text content as-is
- Opens or creates the file with the appropriate flags:
- Append mode: Opens file and adds content to the end (O_APPEND)
- Truncate mode: Clears existing content and writes new data (O_TRUNC)
- Writes the content to the file (permissions: 0644)
- Closes the file
Requirements
- Valid file path (file will be created if it doesn't exist)
- Write permissions in the target directory
- Write Mode must be selected (append or truncate)
- For Base64 mode, content must be valid base64-encoded data
- Sufficient disk space for the content
Error Handling
| Error Code | Description |
|---|---|
Core.FileSystem.WriteFile.ErrOnCreate | Node configuration parsing failed |
Core.FileSystem.WriteFile.ErrOnMessage | Input message parsing failed |
Core.FileSystem.Write.ErrFilePath | File path is empty |
Core.FileSystem.Write.ErrWriteMode | Write mode is not valid (must be append or truncate) |
Core.FileSystem.Write.ErrBase64Decode | Base64 decoding failed (invalid base64 content) |
Core.FileSystem.WriteFile.ErrOpenFile | Cannot open or create file (permission denied or invalid path) |
Core.FileSystem.WriteFile.ErrWrite | Write operation failed (disk full or I/O error) |
Core.FileSystem.WriteFile.ErrClose | Failed to close file |
Usage Examples
Example 1: Write Text to New File
Create a new log file with automation results:
{
"path": "C:\\Logs\\automation_log.txt",
"text": "Automation started at {{ $datetime }}\nProcessed 100 items successfully"
}
Configuration:
- Write Mode: Truncate
- Base64: false
Example 2: Append to Existing Log
Add new entries to an existing log file:
{
"path": "C:\\Logs\\daily_log.txt",
"text": "\n[{{ $datetime }}] New entry: Operation completed"
}
Configuration:
- Write Mode: Append
- Base64: false
Each execution adds a new line to the log.
Example 3: Write Binary File from Base64
Save a base64-encoded image to disk:
{
"path": "D:\\Images\\screenshot.png",
"text": "iVBORw0KGgoAAAANSUhEUgAA..."
}
Configuration:
- Write Mode: Truncate
- Base64: true
Decodes and saves the image as a binary PNG file.
Usage Notes
- Files are created with 0644 permissions (owner read/write, group/others read)
- Append mode adds content to the end without modifying existing content
- Truncate mode completely replaces the file content
- If the file doesn't exist, it will be created regardless of the write mode
- Parent directories must exist; the node does not create parent directories
- Base64 mode is essential for writing binary files (images, PDFs, executables)
- Text content is written as UTF-8 when Base64 is disabled
- Both Base64 and non-Base64 modes use the Write method internally
Tips
- Use Truncate mode when creating new files or replacing file content
- Use Append mode for log files to preserve historical data
- Enable Base64 when writing binary data received from APIs or web services
- Create parent directories with Create File/Dir node before writing if needed
- For large content, ensure sufficient disk space is available
- Use Path Exists to check if you're about to overwrite an important file
- Combine with Read File to implement file transformation workflows
- Add timestamps to log entries for better traceability
- Consider file locking mechanisms when multiple processes write to the same file
Related Nodes
- Read File - Read file content
- Path Exists - Check if file exists before writing
- Create File/Dir - Create parent directories before writing
- Copy File/Dir - Backup files before overwriting