CopyFile

CopyFile[file1,file2]

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
    ExternalStorageObject[]external storage object (e.g. IPFS, Dropbox)
  • 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 the secure file transfer and copy protocols.
  • 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.
  • When copying to a cloud object, CopyFile returns that CloudObject expression.
  • Cloud objects created by CopyFile are assigned the permissions specified by $Permissions.
  • CopyFile has the following option:
  • OverwriteTargetFalsewhether to overwrite if the target file already exists

Examples

open allclose all

Basic Examples  (1)

The name of the file to copy:

Copy the file:

Import the new file:

Delete the file:

Scope  (7)

Copy a file from the local file system to the Wolfram Cloud:

Copy a cloud object to another location within the Wolfram Cloud:

Copy a cloud object to the local file system:

Copy a file specified as a File object:

CopyFile can copy among local files, local objects, and cloud objects:

The source can be any form of web URL:

Copy a file to a remote machine using the scp secure protocol:

Copy a file from a remote machine using the scp secure protocol:

Copy a file to a remote machine using the sftp secure protocol:

Copy a file from a remote machine using the sftp secure protocol:

Copy a file from a remote machine using a different user:

Copy from an ExternalStorageObject to a local file:

Import the resulting file:

Copy from an ExternalStorageObject to a cloud object:

Import the resulting file:

Possible Issues  (1)

Copying to the cloud requires the CloudObject wrapper:

Introduced in 1991
 (2.0)
 |
Updated in 2020
 (12.1)