| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| R2010b Documentation → MATLAB |
| Contents | Index |
| Learn more about MATLAB |
As an alternative to the movefile function, use the Current Folder browser. For more information, see Working with Files and Folders.
movefile('source')
movefile('source','destination')
movefile('source','destination','f')
[status,message,messageid]=movefile(...)
movefile('source') moves the file or folder named source to the current folder, where source is the absolute or relative path name for the folder or file. To move multiple files or folders, use one or more wildcard characters (*) after the last file separator in source. The source argument permits a wildcard character in a path string. movefile does not preserve the archive attribute of source.
movefile('source','destination') moves the file or folder named source to the location destination, where source and destination are the absolute or relative paths for the folder or file. To move multiple files or folders, you can use one or more wildcard characters (*) after the last file separator in source. You cannot use a wildcard character in destination. To rename a file or folder when moving it, make destination a different name than source, and specify only one file for source. When source and destination have the same location, movefile renames source to destination.
movefile('source','destination','f') moves the file or folder named source to the location destination, regardless of the read-only attribute of destination.
[status,message,messageid]=movefile(...) moves the file or folder named source to the location destination, returning the status, a message, and the MATLAB message ID. Here, status is logical 1 for success or logical 0 for error. movefile requires only one output argument.
Assuming myfiles is a subfolder within the current folder, move the file myfunction.m to the current folder:
movefile('myfiles/myfunction.m')Assuming projects/testcases is the current folder, move projects/myfiles and its contents to the current folder:
movefile('../myfiles')In the current folder, rename myfunction.m to oldfunction.m:
movefile('myfunction.m','oldfunction.m')Assuming myfiles is a subfolder of the current folder, move all files whose names that begin with my from the myfiles folder, to the current folder:
movefile('myfiles/my*')Assuming projects and the current folder are at the same level, move the file myfunction.m from the current folder to the folder projects:
movefile('myfunction.m','../projects')Assuming projects is a subfolder of the current folder, move the folder projects/testcases and all its contents down a level in projects into projects/myfiles:
movefile('projects/testcases','projects/myfiles/')Move the file myfile.m from the current folder to d:/work/restricted, assigning it the name test1.m, where restricted is a read-only folder:
movefile('myfile.m','d:/work/restricted/test1.m','f')The read-only file myfile.m is no longer in the current folder. The file test1.m is in d:/work/restricted and is read only.
Move all files in the folder myfiles whose names start with new to the current folder, when there is an error. You mistype new* as nex* and no items in the current folder start with nex*:
[s,mess,messid]=movefile('myfiles/nex*')
s =
0
mess =
No matching files were found.
messid =
MATLAB:MOVEFILE:FileDoesNotExistcd, copyfile, delete, dir, fileattrib, ls, mkdir, rmdir
Working with Files and Folders
| © 1984-2010- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |