fileCopy
Version 24.2.9039
Version 24.2.9039
fileCopy
Copies a file or directory to the path specified.
Required Parameters
- source: The path of the file (including the filename) or directory to copy.
- destination: The path of the file (including the filename) or directory where the file or directory is copied to.
Optional Parameters
- force: Controls whether the operation creates missing directories in the destination path. The allowed values are
true
andfalse
. The default istrue
. This is commonly used in conjunction with the recurse parameter when you need to mirror the directory structure of the source in the destination. - mask: The pattern used to select the entries to be copied. The default value is
*
. (For example, a mask of*.xml
matches all xml files in the source.) - recurse: Recursively copy files and directories from the source. In this case the destination is assumed to be a directory. The allowed values are
false
andtrue
. The default isfalse
.
Output Attributes
- file:source: The full path of the source file or directory.
- file:destination: The full path of the destination file or directory.
Examples
Copy a Single File
<!-- Creating the input item with the associated source and destination attributes -->
<arc:set attr="input.source" value="/tmp/foo/helloworld.txt" />
<arc:set attr="input.destination" value="/tmp/bar/helloworld.txt" />
<!-- Calling fileCopy and passing in the input item -->
<arc:call op="fileCopy" in="input" out="result">
<!-- Optional: Logging information about the copied file to the application log -->
<arc:set attr="_log.info" value="The file located at [result.file:source] was copied to [result.file:destination]"/>
</arc:call>
Recursively Copy a Directory and its Contents
When this script is executed, the directory structure present in /tmp/foo
is mirrored in /tmp/bar
. Only .xml files are copied over from the source to the destination.
<!-- Creating the input item with the associated source and destination attributes -->
<arc:set attr="input.source" value="/tmp/foo" />
<arc:set attr="input.destination" value="/tmp/bar" />
<!-- Adding the optional mask parameter to only copy files in the directory that have the xml file extension -->
<arc:set attr="input.mask" value="*.xml" />
<!-- Setting the recurse parameter to true to recursively copy any files and directories inside the source location -->
<arc:set attr="input.recurse" value="true" />
<!-- Setting the force parameter to true so that the operation creates the necessary directories in the destination -->
<arc:set attr="input.force" value="true"/>
<!-- Calling fileCopy and passing in the input item -->
<arc:call op="fileCopy" in="input" out="result">
<!-- Optional: Logging information about the copied file to the application log -->
<arc:set attr="_log.info" value="The directory [result.file:source] was copied and placed within the following directory: [result.file:destination]"/>
</arc:call>