| Contents | Index |
Copy files and folders using the Current Folder browser. For more information, see Working with Files and Folders.
copyfile('source','destination')
copyfile('source','destination','f')
[status] = copyfile(...)
[status, message] = copyfile(...)
[status,message,messageid] = copyfile(...)
copyfile('source','destination') copies the file or folder named source to the file or folder destination. The values for source and destination are 1 x n strings. Use full path names or path names relative to the current folder. To copy multiple files or folders, use one or more wildcard characters (*) after the last file separator in source. You cannot use a wildcard character in destination.
copyfile('source','destination','f') copies source to destination, even when destination is not writable. The state of the read-write attribute for destination does not change. You can use f with any syntax for copyfile.
[status] = copyfile(...) reports the outcome as a logical scalar, status. The value is 1 for success and 0 for failure.
[status, message] = copyfile(...) returns any warning or error message as a string to message. When copyfile succeeds, message is an empty string.
[status,message,messageid] = copyfile(...) returns any warning or error identifier as a string to messageId. When copyfile succeeds, messageId is an empty string.
The timestamp for destination is the same as the timestamp for source.
When source is a folder, destination must be a folder.
When source is a folder and destination does not exist, copyfile creates destination and copies the contents of source into destination.
When source is a folder and destination is an existing folder, copyfile copies the contents of source into destination.
When source is multiple files and destination does not exist, copyfile creates destination.
For behavior not explicitly stated in the Description or these tips, copyfile follows the behavior of the operating system copy command. For example, on UNIX platforms, copyfile is like the UNIX command cp -p.
Copy myFun.m from the current folder to d:/work/Projects/.
copyfile('myFun.m','d:/work/Projects/')
Copy myFun.m in the current folder, assigning it the name myFun2.m.
copyfile('myFun.m','myFun2.m')
Copy files and subfolders whose names begin with my, from the Projects subfolder within the current folder to the folder newProjects, which is at the same level as the current folder:
copyfile('Projects/my*','../newProjects/')Copy the contents of the Projects subfolder within the current folder to the I:/work/newProjects folder, where newProjects does not exist.
copyfile('Projects','I:/work/newProjects')Copy the contents of myFun.m from the current folder to d:/work/restricted/myFun2.m, where myFun2.m is read-only.
[status,message,messageId]=copyfile('myFun.m', ...
'd:/work/restricted/myFun2.m','f')status =
1
message =
''
messageId =
''The status of 1 and empty message and messageId strings confirm the copy was successful.
cd | delete | dir | fileattrib | filebrowser | fileparts | mkdir | movefile | rmdir
| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |