Skip to main content

Copy File/Dir

Copies the content of a source file/directory to destination file/directory

Common Properties

  • Name - The custom name of the node.
  • Color - The custom color of the node.
  • Delay Before (sec) - Waits in seconds before executing the node.
  • Delay After (sec) - Waits in seconds after executing node.
  • Continue On Error - Automation will continue regardless of any error. The default value is false.
info

if ContinueOnError property is true, no error is caught when the project is executed even if Catch node is used.

Input

  • Source Path - The source path of the file/directory that will be copied.
  • Destination Path - The destination path of the file/directory will be copied.

How It Works

The Copy File/Dir node duplicates files or directories through the following process:

  1. Validates that both source and destination paths are provided
  2. Checks if the source path exists
  3. Uses the copy library to recursively copy the source to the destination
  4. Preserves file contents, directory structure, and subdirectories
  5. Creates parent directories at the destination if they don't exist

Requirements

  • Valid source path to an existing file or directory
  • Valid destination path (directory will be created if it doesn't exist)
  • Read permissions on the source file/directory
  • Write permissions on the destination directory
  • Sufficient disk space at the destination location

Error Handling

Error CodeDescription
Core.FileSystem.Copy.ErrOnCreateNode configuration parsing failed
Core.FileSystem.Copy.ErrOnMessageInput message parsing failed
Core.FileSystem.Copy.ErrSourcePathSource path is empty
Core.FileSystem.Copy.ErrDestPathDestination path is empty
Core.FileSystem.Copy.ErrNotExistSource path does not exist
Core.FileSystem.Copy.ErrCopyCopy operation failed (permission denied, disk full, or I/O error)

Usage Examples

Example 1: Copy a Single File

Copy an Excel file to a backup location:

{
"sourcePath": "C:\\Reports\\monthly_report.xlsx",
"destPath": "D:\\Backups\\monthly_report_backup.xlsx"
}

This creates an exact copy of the file at the destination.

Example 2: Copy an Entire Directory

Copy a directory with all its contents to another location:

{
"sourcePath": "C:\\Projects\\RPA_Project",
"destPath": "D:\\Archive\\RPA_Project_Copy"
}

All files and subdirectories are copied recursively.

Example 3: Timestamped Backup

Create a backup with a timestamp in the filename:

{
"sourcePath": "C:\\Data\\database.db",
"destPath": "C:\\Backups\\database_{{ $datetime }}.db"
}

Use Robomotion variables to generate unique filenames.

Usage Notes

  • The copy operation is recursive by default - all subdirectories and files are copied
  • If the destination file already exists, it will be overwritten
  • Parent directories in the destination path are automatically created if they don't exist
  • File permissions and timestamps are preserved during the copy operation
  • The source path remains unchanged after the copy operation
  • Network paths (UNC paths) are supported for both source and destination

Tips

  • Use timestamped destination paths to avoid overwriting previous backups
  • Verify sufficient disk space before copying large directories
  • For large file operations, consider using the Continue On Error property to handle edge cases
  • Combine with Path Exists node to check if destination already exists before copying
  • Use forward slashes (/) or escaped backslashes (\\) in paths for cross-platform compatibility
  • Consider using Copy instead of Move when you need to preserve the original