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:

Wolfram Research (1991), CopyFile, Wolfram Language function, https://reference.wolfram.com/language/ref/CopyFile.html (updated 2020).

Text

Wolfram Research (1991), CopyFile, Wolfram Language function, https://reference.wolfram.com/language/ref/CopyFile.html (updated 2020).

CMS

Wolfram Language. 1991. "CopyFile." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2020. https://reference.wolfram.com/language/ref/CopyFile.html.

APA

Wolfram Language. (1991). CopyFile. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/CopyFile.html

BibTeX

@misc{reference.wolfram_2023_copyfile, author="Wolfram Research", title="{CopyFile}", year="2020", howpublished="\url{https://reference.wolfram.com/language/ref/CopyFile.html}", note=[Accessed: 28-March-2024 ]}

BibLaTeX

@online{reference.wolfram_2023_copyfile, organization={Wolfram Research}, title={CopyFile}, year={2020}, url={https://reference.wolfram.com/language/ref/CopyFile.html}, note=[Accessed: 28-March-2024 ]}