FUNCTION REFERENCE

copyfile

Copy local files or directory trees.

Copy local files or directory trees.

Syntax

status = copyfile(source, destination)

Syntax

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

Destination defaults to the current folder. A file copied to a directory keeps its basename; a directory source copies its contents into the destination. Wildcard sources create a missing destination folder. Supports final-component * and ? patterns. The f option permits replacing read-only files. Without outputs, failure raises an error.

Example

d=tempname(pwd); mkdir(d); f=fullfile(d,'a'); fclose(fopen(f,'w')); ok=copyfile(f,fullfile(d,'b')); rmdir(d,'s'); ok   % 1

Differences from MATLAB: Local paths only; symbolic links are rejected. Copies are bounded to 256 MiB, 10000 entries and 64 levels. Each file is staged before replacement; cancellation or failure can leave a partially copied directory tree.

These are the engine’s help pages. Each page keeps its compatibility notes. File operations are unavailable in the browser.