copies from the local, remote or cloud file file1 to the local, remote or cloud file file2.

Details and Options

  • CopyFile takes file specifications in the following forms:
  • "path"local file given by the specified relative or absolute path
    File["path"]local file specified by path
    RemoteFile[url]remote file specified by url
    URL["url"]web or other URL
    LocalObject[]persistent local object
    CloudObject[]cloud object
  • In CopyFile[src,dest] the source src can be specified by a URL with any of the following schemes:
  • http:HTTP protocol
    https:secure HTTP protocol
    ftp:file transfer protocol
    sftp:secure file transfer protocol
    scp:secure copy protocol
    file:local file
  • The destination dest can be specified by a URL with any of the following schemes:
  • sftp:remote file accessible through the SFTP protocol
    scp:remote file accessible through the SCP protocol
    file:local file
  • RemoteFile["url",Authentication->auth] can be used to specify authentication information for scp: and sftp: URLs.
  • CopyFile sets the modification date for file2 to be the same as for file1.
  • CopyFile returns the full name of the file it copies to and $Failed if it cannot copy.
  • CopyFile has the following option:
  • OverwriteTargetFalsewhether to overwrite if the target file already exists


open all close all

Basic Examples  (1)

The name of the file to copy:

Click for copyable input

Copy the file:

Click for copyable input

Import the new file:

Click for copyable input

Delete the file:

Click for copyable input

Scope  (4)

Introduced in 1991
Updated in 2019