Skip to content

copyfile

Copy a file to a new location.

copyfile(source, destination)
copyfile(source, destination, 'f')
[status, message, messageid] = copyfile(...)

Copies the file or directory source to destination. The third-argument string 'f' forces overwrite even if the destination exists and is read-only. Three-output form returns status (logical success), message (error text on failure), and messageid (error category).

copyfile('data.csv', 'backup/data.csv')
[ok, msg] = copyfile(src, dst, 'f');
  • movefile — Move (rename) a file or directory.
  • delete — Delete files (or graph objects).
  • mkdir — Create a directory.