Contents

Roo

FileUtils.move()

Moves the source file to the destination.

FileUtils.move(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 move. 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 moved 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 source is moved. 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 move operation. If overwrite is False then no files will be deleted/overwritten

Returns

  • True if the move 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.move(source, "/Users/garry/Downloads", False) # Move the file to the Downloads folder.

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