Copy File
Copy File
Section titled “Copy File”Type: copy-file · Package: Filesystem Activities v1.0.6 · Output: string
Copies a file from a source path to a destination path, leaving the original in place. Use it to back up a file before changing it, duplicate a template, or distribute a document to several folders.
How it works
Section titled “How it works”Copies the file at source to destination.
- Destination:
destinationis the full path of the new file (folder + name), not just the folder. To keep the name, usepathJoin(destinationFolder, fileName(source)). - Folders: if the destination folder does not exist, it is created (with any intermediate ones).
- Overwriting: by default it does not overwrite: if the destination exists, the activity fails (unless you set
overwrite = true). - Files only: it copies one file; to copy a whole folder, list it with List Files and copy each file.
Required parameters
Section titled “Required parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
source | string | — | Path of the source file. |
destination | string | — | Full path of the destination file (folder + name). |
Optional parameters
Section titled “Optional parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
overwrite | bool | false | Replace the destination if it already exists. |
Output
Section titled “Output”Returns a string with the destination path of the copied file (as you gave it in destination).
Common errors
Section titled “Common errors”| Message | Cause and fix |
|---|---|
Could not find file '…'. | The source file does not exist. Check it first with File Exists. |
The file '…' already exists. | The destination exists and overwrite is false. Set overwrite = true or use a unique name (for example with the date). |
The process cannot access the file '…' because it is being used by another process. | The source or destination is open in another program. |
Access to the path '…' is denied. | No permission on the source or the destination folder. |
'source' is required. / 'destination' is required. | The parameter’s expression evaluated to null. |
Example
Section titled “Example”Back up a file with the date in its name and log where it went:
Copy File source = "C:/data/master.xlsx" destination = "C:/backups/master_" + today().ToString("yyyyMMdd") + ".xlsx" overwrite = true → output: backupLog message = "Backup created at " + backupRelated activities
Section titled “Related activities”- Move File — move instead of copy (the original is gone).
- File Exists — check before copying.
- List Files — copy several files from a folder.