Contents

Roo

File.copy_to()

The copy_to() method has two possible signatures:

file.copy_to(destination as File, overwrite as Boolean) as Boolean
file.copy_to(destination_path as Text, overwrite as Boolean) as Boolean

Copies this File object’s file to the specified destination.

Parameters

  • destination. File or Text. This parameter specifies the folder that will become the new parent folder of the file to be copied. If destination is a Text object then it may be either a relative path (relative to the currently executing script) or an absolute path
  • overwrite. Boolean. If this File object is a folder and destination contains (at its top level) an identically named folder and overwrite is True then the folder within destination will be deleted before the copy is done. Similarly, if this File object is a file and destination contains an identically named file at its top level and overwrite is True then the file at destination will be deleted prior to the copy operation. If overwrite is False then no files will be deleted/overwritten

Returns

  • True if the copy was successful, False if it fails

Notes

  1. Text paths use forward slashes (/) as separators
  2. Absolute paths begin with a forward slash, relative paths do not

Example

var source = File("/Users/garry/Desktop/test.txt")
source.copy_to("/Users/garry/Downloads", False) # Copy the file to the Downloads folder.

var destination = File("/Users/garry/Pictures/My Folder")
source.copy_to(destination, False)