%% Copy File to Read-Only Folder
% Copy the file myfile1.m from the current folder to the read-only folder  restricted.
% Create the read-only folder restricted.

mkdir restricted
fileattrib restricted -w

%
% Copy and rename the file myfile1.m. A status of 0 shows the copy was unsuccessful.

status = copyfile('myfile1.m', 'restricted');
status

%
% Copy the file myfile1.m using the 'f' option to override the read-only status of the destination folder. A status of 1 and an empty message and messageId confirm the copy was successful.

[status,message,messageId] = copyfile('myfile1.m', 'restricted', 'f');
status
message
messageId

% Copyright 2012 The MathWorks, Inc.