--- alias: user-guide-automation-task-filedrivers-copy tags: - automation tasks description: "This task copies files or directories to a specified destination with configurable retry behavior" --- # Copy ![Screenshot showing a file copying process.](images/copyfile-lg.svg) When activated, the `copy` task will copy a given file or directory (`source`) to a different location (`destination`). The `source` and `destination`, can be provided either by the input port or in the task settings. ![Screenshot showing a copy operation with source labeled as "Sxring" and destination labeled as "destination".](./images/image8.png) ## Inputs | Name | DataType | Description | |----------------------|-----------|-------------------------------------------------------------------------------------------------| | source | `String` | Source file/directory | | destination | `String` | Destination file/directory | | overwrite | `Boolean` | Overwrite existing file or directory | | preserveTimestamps | `Boolean` | When true, will set last modification and access times to the ones of the original source files | | recursive | `Boolean` | If the source is a directory, should the subdirectories be copied as well | | attempts | `Integer` | Number of attempts to perform this operation. Default is 1 attempt | | sleepBetweenAttempts | `Integer` | Interval of time between the attempts. Default is 1000ms | | Activate | `Any` | Activate the task | ## Outputs | Name | DataType | Description | | ------ | --------- | --------- | | Success | `Boolean` | Triggered when the task is executed with success | | Error | `Error` | Triggered when the task failed for some reason | ## Settings On the `General` tab, you have the usual settings and the following settings: | Name | DataType | Values | Default | Description | | ------ | --------- | --------- | --------- | --------- | | Source | `String` | | | Source file/directory | | Destination | `String` | | | Destination file/directory | | Overwrite | `Boolean` | | False | Overwrite existing file or directory | | Preserve timestamps | `Boolean` | | True | When true, will set last modification and access times to the ones of the original source files | | Recursive | `Boolean` | | True | If the source is a directory, should the subdirectories be copied as well | | Number of attempts | `Integer` | | 1 | Number of attempts to perform this operation. | | Sleep Between Attempts | `Integer` | | 1000 | Interval of time between the attempts. | For the `Source` and `Destination` settings you can use tokens as represented below: ```bash Available tokens: ${path} - Watched path ${archive} - Archive path ${temp} - Temporary directory of the user ${id} - DriverId ("\" chars replaced with "_") Examples: ${path}\subdir\file.txt ${temp}\files\${id}\file.txt c:\dsource\file.txt ``` ![Screenshot showing settings options.](./images/image9.png) ## Behavior In this task you choose a driver when dropping it into the workflow (if you have more than one driver associated with the controller). Upon activation, will send a `Copy` command to the driver where it will try to copy the `source` location (file or directory) into the `destination` location. If it fails, will retry `attempts` times, waiting `sleepBetweenAttempts` milliseconds each time. If the operation is executed with success, a value `true` is emitted on the `Success` output. In case of the task , for some reason, is not able perform the `copy` operation, an `Error` is emitted. ## Remarks There is no particular remark to be made.