Skip to content

copyfile

miscellaneous · scripts/miscellaneous/copyfile.m

: copyfile (source, destination)
: copyfile (source, destination, "f")
: [status, message, messageid] = copyfile (…)

Copy files and folders.

source is a file, a folder, a wildcard pattern (‘*’, ‘?’ or ‘[…]’), or a cell array of such names. destination is either an existing folder, in which case everything is copied into it under its own name, or the new name of a single file or folder. Folders are copied together with their contents.

An existing file is overwritten, a read-only one only when the option "f" is given. Copying something onto itself, or a folder into itself, fails.

With output arguments nothing is raised on failure: status is true after success and false otherwise, and message and messageid describe the failure (both are empty on success). Without outputs a failure is an error.