CopyFile

Summary

The CopyFile function copies one or more files from a source directory to a destination directory. The source and target directories are located on Connect’s SFTP server file system.

Syntax

CopyFile([FilePath=<path to file>]
[, Directory=<directory>]
, Destination=<directory>
[, Filter=<wildcard filter>]
[, Regex=<regular expression>]
[, Overwrite=true|false])

Parameters

Parameter Description
FilePath (Optional) String value or expression containing the full Unix-style path name and source file name to copy a single file. If no path is given, the root SFTP directory is assumed. The Directory, Filter, and Regex parameters are ignored when theFilePath is specified.
Directory (Optional) String value or expression with a directory name or directory path when copying more than one file. Format is Unix-style. Filter and Regex parameters limit the file names to copy and are used in lieu of a filename in FilePath.
Destination (Required) The target directory path.The destination is always assumed to be a directory path. You cannot specify the target filename  (source filenames will be used to create target file names). Unix-style directory path. The copy command will create any directories if they do not already exist.
Filter (Optional) String value containing wildcard search expressions to specify source files to copy. Restricts the result set to only those files and directories matching the filter expression.
Regex (Optional) Use when you require more complicated search patterns. A string value containnig a Java regular expression.
Overwrite (Optional) Default is false. If the Overwrite parameter is true, files copied from the source directory overwrite existing files in the destination. When the Overwrite parameter is false, existing files in the destination directory are not overwritten.

Details

Connect is integrated with Xactly’s SFTP server, connectftp.xactlycorp.com. Connect’s file commands can read and write files and manipulate directory structures located on the SFTP file system. An SFTP account is not required to use these functions. However, one is required to access the file system via SFTP clients. Contact Xactly Customer Support to setup an SFTP account if your business does not already have one.

The result of the CopyFile function is a status result set indicating the success or failure of each attempted file copy.

Examples

call CopyFile(FilePath='/tmp/foo.csv', Destination='/tmp/bar');

copyfile_01

call CopyFile(Directory='/tmp', Filter='*.csv', Destination='/temp');

copyfile_02

Related Commands

DirList

Exists

WriteFile