Write To File Action

Declaration

<AMFILEWRITE FILE="text" DATA="text" APPEND="yes/no" BYTESVARIABLE="text">

See Also

Write to File Action-Setting Properties, Copy File, Move File, Delete File, Delete Folder, Rename Folder

Description

Writes the data specified to a file. The data is either overwriting the file or is appened at the end of the file.

Practical Usage

To write data to a text file.

Parameters

General Tab

File

Text, Required
MARKUP: FILE="c:\sourcefoldername\file.txt"

Specifies the file(s) that the data should be written to.

Append

Yes/No, Optional Default= YES
MARKUP: APPEND="NO"

Specifies whether the data should be appended to the end of the file as a new line or should overwrite all the data in the file. The available options are:

yes: The data will be appended onto the end of the file as a new line

no: The data will be overwritten

Write Data

Text, Required
MARKUP:
a) DATA="Text to be written goes here"
b) DATA="%varname%"

Specifies the data to write to the file. As with every text parameter, if the data you wish to write is contained in a variable simply type the variable name surrounded by percentage signs to resolve it to it's contents at runtime (e.g. %varname%).

Populate Variable with Number of Bytes Written

Text, Required
MARKUP: BYTESVARIABLE="varname"

Specified the name of the variable to populate with the number of bytes that were written to the file. The variable must have been created using a Create Variable <AMCREATEVAR> previous step.

Notes

Custom Description

This action includes the Description tab for entering a custom step description.

More on setting custom step description

Standard Error Handling Options

This action also includes the standard Error Causes and On Error failure handling options/tabs.

More on Error Handling Options

Variables and Expressions

All text fields allow the use of expressions, which can be entered by surrounding the expression in percentage signs (example: %MYVARIABLE%, %Left('Text',2)%). To help construct these expressions, you can open Expression Builder from these fields by pressing F2.

More on variables
More on expressions

More on the expression builder

Example

NOTE: The code below can be copied and pasted directly into the Steps pane of the Task Builder.

<AMFILEWRITE FILE="C:\test.txt" WRITEDATA="This is the text I want to write to the end of the file" VARIABLENAME="varname">