Writing Content to a File
After you create a basic write action as described in
Creating a Basic File Operation
Action, use this procedure to set the properties of the action.
To set the properties for the write action
1. In the Source Filter box, enter the name of the file to trigger this event. By default, ActiveTransfer Server considers all files.
Note: You can use wildcard characters to filter the file names. For example, enter *.txt to trigger the event only when text files are uploaded or downloaded. To trigger an event based on a name string in the text files, use the name string in the Source Filter box, preceded and followed by wildcard characters. For example, enter *invoice*.txt to trigger the event based on the file URLs, when text files containing the character string invoice in their file names are uploaded or downloaded. If you define a Source Filter for an action, the action acts only on the files that are filtered out.
For information on the use of wildcards in
ActiveTransfer Server, see
Use of Special Characters in Search.
2. If you want to use regular expression in the source filter, specify a valid regular expression in Source Filter and select Use regular expression.
Examples for regular expressions:
(.(?!purchaseorder))* | Excludes files with the file URL containing purchaseorder |
.*/out/.* | Include files with the file URL containing the folder out |
^abc(.*)123$ | Includes anything that starts with abc and ends with 123. Matches abc123, abcxyz123, but not abcxyz123def |
NEW-((*.doc)|(*_backup_*)) | Includes anything starting with NEW- that either ends in .doc, or is followed by the string _backup_ |
3. In the File Path box, enter the path containing the file to write to.
Important: Be sure to end the path with a slash character (“/”) to identify the location as a folder and not a file.
4. If the file already exists and you want to replace the entire contents of the existing file with the new content, select the Overwrite check box.
5. If the file does not exist, type or paste the content to write to the file in the Contents If File Does Not Exist box.
6. If you want to insert new content before existing content in the file, select Add before and then do one of the following:
If you want to insert the content at the beginning of the file, select
Beginning of file and then type or paste the new content in the
Contents box.
If you want to insert the content before a specific string of existing content in the file, select
Find, enter the string in the box beneath this option, and then type or paste the new content in the
Contents box.
7. If you want to insert new content after existing content in the file, select Add after and then do one of the following:
If you want to insert the content at the end of the file, select
End of file and then type or paste the new content in the
Contents box.
If you want to insert the content after a specific string of existing content in the file, select
Find, enter the string in the box beneath this option, and then type or paste the new content in the
Contents box.
8. If you want to execute an error action if the file operation fails, select Execute error action.
9. Click Save.
10. If you selected the Execute error action check box, define an error action as described in Defining an Error Action. 11. If you are finished defining actions for this event, activate the event as described in Activating an Event. Result:
The “Write Content to File” action adds the specified information about the list of files to an existing file in File Path or to a new file created for this purpose. After the successful execution of the action, the list of files from the previous action is passed on to the subsequent action. The file created or modified by this action is not passed on to the next action.
Example: An event configured with the following actions:
1. Find action: Find files in File URL = <source folder>
2. Write Content to File action: Writes information regarding the files in a specified file
3. Move Action: Moves the files to the destination URL = <destination folder>
The event results in the following:
1. Find action lists all the files in the <source folder>.
2. The Write Content to File action writes information on the files passed on to it by the find action. For example, the action could write the file names of all the files passed on to it to a <file.ext> file specified in the action.
3. Move action moves the files that are encrypted by the encrypt action to the <destination folder>.