Main Content

Move, Rename, Copy, or Delete Project Files

Move or Add Files

To move or add project files, you can drag them to the project, or use clipboard operations.

  • To add files to your project, you can paste files or drag them from your operating system file browser or the MATLAB® Current Folder browser onto the Project files view in the project. When you drag a file to the Project files view, you add the file to the project. For projects under source control, you also add the file to source control.

  • To move files within your project, cut and paste or drag files in the project.

See also Add Files to the Project.

Automatic Updates When Renaming, Deleting, or Removing Files

When you rename, delete, or remove files or folders in a project, the project checks for impact in other project files. You can find and fix impacts such as changed library links, model references, and model callbacks. You can avoid refactoring pain tracking down other affected files. Automatic renaming helps to prevent errors that result from changing names or paths manually and overlooking or mistyping one or more instances of the name.

For example:

  • When renaming a library, the project offers to automatically update all library links to the renamed library.

  • When renaming a class, the project offers to automatically update all classes that inherit from it. If you rename a .m or .mlx file, the project offers to automatically update files and callbacks that call it. The project does not automatically update .mlx files. You need to update them manually.

  • When deleting files or removing them from the project, the project prompts you if other files refer to them. You must decide how to fix the affected files manually.

  • When renaming a C file, the project prompts you to update the S-function that uses it.

  • When renaming buses or bus elements using the Simulink® Type Editor, the project prompts you to update all usages in the project.

    You can disable the project prompt and analysis when renaming buses or bus elements while keeping automatic updates enabled for other files. On the MATLAB Home tab, in the Environment section, click Preferences. Select MATLAB > Project and clear Detect project-wide references when renaming Simulink buses and bus elements.

You can disable the automatic updates when renaming, deleting, or removing files in a project. On the MATLAB Home tab, in the Environment section, click Preferences. Select MATLAB > Project and clear Detect project-wide references when renaming, removing, and deleting files.

To use automatic updates:

  1. Rename a model, library, or MATLAB file in a project.

    The project runs a dependency analysis to look for impacts in other files.

  2. In the Rename dialog box, you can examine impacted files, choose to rename and update, just rename, or cancel renaming the file.

  3. If you choose automatic updates, you can examine the results in updated files.

Automatic Renaming Using the Power Window Project

  1. Open the power window example project.

    openExample('simulink_automotive/PowerWindowControlProjectExample')
    
    The project opens the top model, some scopes, and an animation window.

  2. In the project, expand the model folder, and rename the slexPowerWindowControl.slx model to slexPowerWindowControlSystem.slx.

    The project runs a dependency analysis to look for impacts in other files, and then the Rename dialog box reports impacted files.

  3. In the Rename dialog box, click Show impacted files. Expand the last impacted file to view the dependency, which is a model reference.

  4. To view the dependency highlighted in the model, double-click the last Model Reference line in the Rename dialog box. Observe the model name on the highlighted control block, slexPowerWindowControl.

  5. In the Rename dialog box, click Rename and Update.

    The project updates the impact files to use the new model name in model references. When the project can automatically rename items, it reports success with a check mark. With some impacts, you must decide how to fix the affected files manually.

  6. Examine the results by double-clicking items in the Rename dialog box. Double-click the last Model Reference line. Check if the model name on the highlighted control block is updated to slexPowerWindowControlSystem.

Related Topics