Contents

Roo

FileUtils.copy()

Copies the source file to the destination.

FileUtils.copy(source as File or Text, destination as File or Text, overwrite as Boolean) as Boolean

Parameters

  • source: File or Text object. The file or folder to copy. It should be a valid relative or absolute path or a valid File object.
  • destination: File or Text object. The folder that source should be copied into. It should be a valid relative or absolute path or a valid File object.
  • overwrite. Boolean. If source 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 source 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")
FileUtils.copy(source, "/Users/garry/Downloads", False) # Copy the file to the Downloads folder.

var destination = File("/Users/garry/Pictures")
FileUtils.copy(source, destination, False)