| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → MATLAB |
| Contents | Index |
| Learn more about MATLAB |
As an alternative to the movefile function, use the Current Folder browser.
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 an * 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.
Move the file myfiles/myfunction.m to the current folder:
movefile('myfiles/myfunction.m')Move projects/myfiles and its contents to the current folder, when the current folder is projects/testcases:
movefile('../myfiles')Rename myfunction.m to oldfunction.m:
movefile('myfunction.m','oldfunction.m')Move all files in the folder myfiles, whose names begin with my, to the current folder:
movefile('myfiles/my*')Move the file myfunction.m from the current folder to the folder projects, where projects and the current folder are at the same level:
movefile('myfunction.m','../projects')Move the folder projects/testcases and all its contents down a level in projects to 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* mistyped as nex* and no items in the current folder start with nex*:
[s,mess,messid]=movefile('myfiles/nex*')
s =
0
mess =
A duplicate filename exists, or the file cannot be found.
messid =
MATLAB:MOVEFILE:OSErrorcd, copyfile, delete, dir, fileattrib, ls, mkdir, rmdir
![]() | move | movegui | ![]() |

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |