Manage Files and Folders

This table shows how to create, open, move, and rename files and folders.

ActionTools WorkflowFunction Alternative
Create a new folder

In the Current Folder browser, right-click in white space, and then select New Folder.

MATLAB® creates and selects a folder named New Folder in the current folder.

Use the mkdir function. For example, create a subfolder named newdir in a parent folder named parentFolder:

mkdir('parentFolder','newdir');
Move a file or folder

In the Current Folder browser, click and drag the item.

You cannot move a folder while it is on the search path.

Use the movefile function. For example, move the file named myfile.m in the current folder to the folder, d:/work:

movefile('myfile.m','d:/work');
Rename a file or folder

In the Current Folder browser, right-click the item and select Rename.

File names must start with a letter, and can contain letters, digits, or underscores.

Use the movefile function. For example, in the current folder, rename myfunction.m to oldfunction.m:

movefile('myfunction.m','oldfunction.m');
Open a file in MATLAB

On the Home tab, in the File section, click Open , and then select a file to open.

To open a file in the Editor as a text file, even if the file type is associated with another application or tool right-click the file in the Current Folder browser and select Open as Text.

Use the open function. The file opens in MATLAB or in an external application, depending on the file extension.

Open a file in another programIn the Current Folder browser, right-click the file and select Open Outside MATLAB. The file opens in the application or tool that the operating system associates with the file type.
Preview file contents without opening the fileIn the Current Folder browser, right-click the file and select Show Details. The Details Panel expands.none
Delete a file or folder

In the Current Folder browser, select the file or folder and press Delete.

By default, MATLAB deletes or recycles files and folders according to your operating system preferences. To permanently remove the selection when the system preference is set to recycle, press Shift+Delete

On Linux® systems, you can request that MATLAB move deleted files to a temporary folder by setting the Deleting files preference. Access this preference on the Home tab, in the Environment section, by clicking Preferences. Select MATLAB > General.

To delete a file, use the delete function. For example, delete a file named myfile.m in the current folder:

delete('myfile.m');

By default, files are permanently removed. To move deleted files to a temporary folder instead, use the recycle function or set the Deleting files preference.

To delete a folder, use the rmdir function.

    Note:   You cannot recover folders deleted using rmdir.

To open the Current Folder browser if it is not visible, do the following: on the Home tab, in the Environment section, click Layout. Then, under Show, select Current Folder. Double-clicking a subfolder displays its contents, and makes that folder the current folder.

See Also

| | | | | |

More About

Was this topic helpful?