File Operations
Version 22.0.8481
File Operations
File Operations allow you to perform standard file input/output. These operations can be used move files across directories, log job results, and much more.
The example below uses the fileWrite operation in the Post Job Event to write a new line to a logfile:
<api:info title="After Run" desc="This event is fired after running a job.">
<input name="JobName" required="true" desc="The name of the job being executed." />
<input name="Source" required="true" desc="The name of source connection." />
<input name="Destination" required="true" desc="The name of destination connection." />
<input name="JobStatus" required="true" desc="The status of the completed run."/>
<input name="Query#" required="true" desc="An array containing each query that was executed." />
<input name="QueryStatus#" required="true" desc="An array containing the status of each query that was executed." />
</api:info>
<api:set attr="file.file" value="C://mylog.log"/>
<api:set attr="file.data" value="[null | now()]: The Job [_input.jobname] completed with a status of [_input.jobstatus]"/>
<api:set attr="file.mode" value="truncate"/>
<api:call op="fileWrite" in="file"/>
Operations
fileCopy
Copies a file or directory to the path specified.
Required Input Attribute |
Description |
source |
The name of the file to be copied. |
destination |
The name of the file after copying. |
Optional Input Attribute |
Description |
force |
If force is set to true, the operation will create missing directories. The allowed values are ‘true, false’. The default value is ‘true’. |
mask |
The pattern that will be used to select the entries to be copied. The default value is ‘*’. |
recurse |
Recursively copy files and directories. In this case the destination is assumed to be a directory. The allowed values are ‘false, true’. The default value is ‘false’. |
Ouptut Attribute |
Description |
file:source |
The full path of the source file. |
file:destination |
The full path of the destination file. |
fileCreate
Creates a text file, and optionally writes to it.
Required Input Attribute |
Description |
file |
The name of the file to be created. |
Optional Input Attribute |
Description |
force |
If force is set to true, the operation will create missing directories. The allowed values are ‘true, false’. The default value is ‘true’. |
data |
The data to be written in the file. |
mode |
The mode of writing. The allowed values are ‘truncate, append’. The default value is ‘truncate’. |
encoding |
The encoding of the file. The default value is ‘UTF-8’. |
Ouptut Attribute |
Description |
file:file |
The full path of the file created. |
file:cdate |
The creation date of the file. |
fileDelete
Deletes a file or directory.
Required Input Attribute |
Description |
file |
The name of the file or directory to be deleted. |
Ouptut Attribute |
Description |
file:file |
The name of the file or directory that got deleted. |
fileListDir
Lists the files and directories in the specified path.
Required Input Attribute |
Description |
path |
The path whose directories and files will be listed. The default value is ‘.’. |
Optional Input Attribute |
Description |
mask |
The pattern that will be used for filtering the result entries. The default value is ‘*’. |
recurse |
To list entries recursively. The allowed values are ‘false, true’. The default value is ‘false’. |
fileordir |
To list only files or directories. The allowed values are ‘all, files, dirs’. The default value is ‘all’. |
Ouptut Attribute |
Description |
file:fullname |
The full path of the file or directory in the current entry. |
file:name |
The name of the file or directory in the current entry. |
file:mtime |
The time at which the file or directory in the current entry was written to. |
file:ctime |
The time at which the file or directory in the current entry was created. |
file:atime |
The time at which the file or directory in the current entry was last read from or written to. |
file:attributes |
A list of attributes of the file or directory in the current entry. |
file:extension |
The extension of the entry. |
file:size |
The size of the file in bytes. |
file:isdir |
Whether the entry is a file or directory. |
fileMakeDir
Creates the directory specified by the path.
Required Input Attribute |
Description |
path |
The path of the directory to be created. |
Optional Input Attribute |
Description |
force |
If force is set to true, the operation will create missing directories. The allowed values are ‘true, false’. The default value is ‘true’. |
Ouptut Attribute |
Description |
file:path |
The directory created. |
file:cdate |
The create date of the directory. |
fileMove
Moves a file or directory to the path specified.
Required Input Attribute |
Description |
source |
The source path to be moved. |
destination |
The destination to be moved to. |
Optional Input Attribute |
Description |
force |
If force is set to true, the operation will create missing directories. The allowed values are ‘true, false’. The default value is ‘true’. |
Ouptut Attribute |
Description |
file:source |
The full path of the source file. |
file:destination |
The full path of the destination file. |
fileRead
Reads a text file and pushes the data out.
Required Input Attribute |
Description |
file |
The name of the file to read. |
Optional Input Attribute |
Description |
encoding |
The encoding of the file. The default value is ‘UTF-8’. |
Ouptut Attribute |
Description |
file:data |
The file data. |
fileReadLine
Reads a text file and pushes the next line out.
Required Input Attribute |
Description |
file |
The name of the file to read. |
Optional Input Attribute |
Description |
separator |
The separator of the file The default value is ‘the newline character’. |
encoding |
The encoding of the file. The default value is ‘UTF-8’. |
Ouptut Attribute |
Description |
file:line |
The line number of the file. |
file:data |
The file data. |
fileWrite
Reads a text file and pushes the data out.
Required Input Attribute |
Description |
file |
The name of the file to read. |
data |
The data to be written in the file. |
Optional Input Attribute |
Description |
force |
If force is set to true, the operation will create missing directories. The allowed values are ‘true, false’. The default value is ‘true’. |
mode |
The mode of writing. The allowed values are ‘truncate, append’. The default value is ‘truncate’. |
encoding |
The encoding of the file. The default value is ‘UTF-8’. |
Ouptut Attribute |
Description |
file:file |
The full path of the file written to. |
file:cdate |
The modified date of the file. |