copyfile

Copy files or folder.

Syntax

  • copyfile(source, destination)
  • [status, msg] = copyfile(source, destination)
  • [status, msg] = copyfile(source, destination, 'f')

Input argument

  • source - a string: file or directory.
  • destination - a string: file or directory.
  • 'f' or 'F' - force copy even destination is not writable.

Output argument

  • status - a logical true or false
  • msg - a string: error message

Description

copyfile(source , destination) copies the file or directory , source (and subdirectories) to the file or directory, destination.

If source is a directory, destination can not be a file.

copyfile replaces existing files without warning.

Example

copyfile([nelsonroot(), '/etc/startup.m'], [tempdir(), 'startup.m'])
[status, msg] = copyfile([nelsonroot(), '/etc/startup.m'], [tempdir(), 'startup.m'])

See also

isdir, rmfile.

History

VersionDescription
1.0.0initial version
1.4.0input arguments support scalar string array type

Author

Allan CORNET