Scilab Website | Contribute with GitLab | Mailing list archives | ATOMS toolboxes
Scilab Online Help
2026.0.0 - Français


copyfile

copies a file

Syntax

copyfile(source, destination)
copyfile(source, destination, mode)
[status, errmsg] = copyfile(...)

Arguments

source

a character string: a filename or a directory name.

destination

a character string: a directory name.

mode

character string: option to modify the way to copy.

"osdefault" (default) copy the file using default OS functions. "preserve" preserve symbolic links instead of copying the file content. "resolve" copy the file content.

status

double: 1 if the copy operation succeeded, 0 otherwise.

errmsg

a character string: the error message if any, or an empty string if no error occurred.

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.

[status, errmsg] = copyfile(source, destination) copies source to destination, returning the status and a errmsg.

Whatever the operating system, if the copy succeeds, the status is 1 and the errmsg is empty; if the copy fails, the status is 0 and the errmsg is not empty.

Timestamps and symbolic links are preserved when using the "preserve" option.

On Windows, symbolic links might require special privilege.

Examples

copyfile(SCI+"/etc/scilab.start",TMPDIR+"/scilab.start")
[status, msg] = copyfile(SCI+"/etc/scilab.start",TMPDIR);

See also

Report an issue
<< file_system file_system deletefile >>

Copyright (c) 2022-2025 (Dassault Systèmes S.E.)
Copyright (c) 2017-2022 (ESI Group)
Copyright (c) 2011-2017 (Scilab Enterprises)
Copyright (c) 1989-2012 (INRIA)
Copyright (c) 1989-2007 (ENPC)
with contributors
Last updated:
Thu Oct 16 09:08:42 CEST 2025