Remove folder - MATLAB rmdir - MathWorks Italia (2024)

Remove folder

collapse all in page


rmdir folderName

rmdir folderName s

status = rmdir(___)

[status,msg]= rmdir(___)

[status,msg,msgID]= rmdir(___)



rmdir folderName removesthe folder folderName from the current folder. folderName mustbe empty. If the operation is not successful, MATLAB® throws anerror to the Command Window.


rmdir folderName s also attempts to remove all subfolders and files in folderName, regardless of their write permissions. The result for read-only files follows the practices of the operating system.


status = rmdir(___) removes the specified folder and returns a status of 1 if the operation is successful. Otherwise, rmdir returns 0. Warnings and errors are not thrown to the Command Window. You can use this syntax with any of the input argument combinations in the previous syntaxes.


[status,msg]= rmdir(___) also returns the message text for any warning or error that occurs.


[status,msg,msgID]= rmdir(___) also returns the message ID for any warning or error that occurs.


collapse all

Remove Folders from Current Folder

Open Live Script

Create the folders myproject and myproject/myfiles in the current folder, and then remove them.

mkdir myprojectmkdir myproject/myfilesrmdir myproject/myfilesrmdir myproject

Remove Nonempty Folder

Open Live Script

Remove the folder myfiles, which contains the files myfile1.m and myfile2.m.

Create the folder myfiles and move the files myfile1.m and myfile2.m from the current folder into the new folder.

mkdir myfilesmovefile myfile1.m myfilesmovefile myfile2.m myfiles

Try to remove the folder myfiles using rmdir. Because the myfiles folder is not empty, the operation fails and returns a status of 0 and an error message detailing why the operation failed.

[status, message, messageid] = rmdir('myfiles')
status = logical 0
message = ''myfiles' was not removed. The directory must be empty before removing.'
messageid = 'MATLAB:RMDIR:DirectoryNotRemoved'

Now, use the 's' flag to remove the folder myfiles. A status of 1 and an empty message and messageid indicate that the operation is successful.

[status, message, messageid] = rmdir('myfiles', 's')
status = logical 1
message = 0x0 empty char arraymessageid = 0x0 empty char array

Input Arguments

collapse all

folderNameFolder name
character vector | string scalar

Folder name to remove, specified as a character vector or string scalar. Specify folderName as an absolute or relative path.

Data Types: char | string

Output Arguments

collapse all

status — Folder removal status
0 | 1

Status of folder indicating if the attempt to remove the folder is successful, specified as 0 or 1. If the attempt is successful, status is 1. Otherwise, status is 0.

Data Types: logical

msg — Error message
character vector

Error message, specified as a character vector. If an erroror warning occurs, msg contains the message textof the error or warning. Otherwise, msg is empty, ''.

msgID — Error message identifier
character vector

Error message identifier, specified as a character vector. Ifan error or warning occurs, msgID contains themessage identifier of the error or warning. Otherwise, msgID isempty, ''.


  • You can use rmdir to create folders in remote locations. To write to a remote location, folderName or parentName must contain the full path of the file specified as a uniform resource locator (URL) of the form:




    It is also valid to use one or three "slash" (/) characters between schema_name and path_to_file. For example:




    Based on your remote location, schema_name can be one of the values in this table.

    File Systemschema_name
    Amazon S3™s3
    Windows Azure® Blob Storagewasb, wasbs

    As with local folders, rmdir cannot remove nonempty virtual folders unless you specify the s flag. Some file services do not support empty folders. On these services, if rmdir removes folders and leaves their parent folder empty, then the parent folder will be removed as well. For more information, see Work with Remote Data.

Alternative Functionality

In the Current Folder browser, right-click the folder name and select Delete from the context menu. To open the Current Folder browser, use the Current Folder Browser command.

Extended Capabilities

Thread-Based Environment
Run code in the background using MATLAB® backgroundPool or accelerate code with Parallel Computing Toolbox™ ThreadPool.

Version History

Introduced before R2006a

expand all

Starting in R2020a, on UNIX® platforms, the wildcard expression *.* no longer matches folders or files without an extension. In previous releases, the expression matches folders or files regardless of extension, including files without an extension. This change of behavior does not apply to Microsoft® Windows® platforms.

See Also

copyfile | dir | delete | movefile | mkdir | Current Folder Browser

Comando MATLAB

Hai fatto clic su un collegamento che corrisponde a questo comando MATLAB:


Esegui il comando inserendolo nella finestra di comando MATLAB. I browser web non supportano i comandi MATLAB.

Remove folder - MATLAB rmdir- MathWorks Italia (1)

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list:


  • América Latina (Español)
  • Canada (English)
  • United States (English)


  • Belgium (English)
  • Denmark (English)
  • Deutschland (Deutsch)
  • España (Español)
  • Finland (English)
  • France (Français)
  • Ireland (English)
  • Italia (Italiano)
  • Luxembourg (English)
  • Netherlands (English)
  • Norway (English)
  • Österreich (Deutsch)
  • Portugal (English)
  • Sweden (English)
  • Switzerland
    • Deutsch
    • English
    • Français
  • United Kingdom (English)

Asia Pacific

Contact your local office

Remove folder - MATLAB rmdir
- MathWorks Italia (2024)


How do I remove a folder in MATLAB? ›

In the Current Folder browser, right-click the folder name and select Delete from the context menu. To open the Current Folder browser, use the Current Folder Browser command.

How do I remove a directory from MATLAB not empty? ›

If the directory is not empty, you must use the s argument. If dirname is not in the current directory, specify the relative path to the current directory or the full path for dirname . rmdir('dirname',' s ') removes the directory dirname and its contents from the current directory.

How to remove a path from MATLAB path? ›

You can remove one or more folders from the path using the rmpath function. To save changes to the search path across MATLAB sessions, use the savepath function. This function also saves changes that you make interactively with the Set Path dialog box, from the Current Folder browser, or in the MATLAB Editor.

How to delete files in MATLAB online? ›

Select MATLAB > General. To delete a file, use the delete function. For example, delete a file named myfile.

What is the command to remove a folder? ›

To delete folders and subfolders on Windows 10, open Command Prompt (admin) and run the “rmdir” command, for example, “rmdir /s C:\files”. You can also open PowerShell (admin) and run the “Remove-Item” command, for example, “Remove-Item -Recurse -Force C:\files”.

How do I undo a delete folder in MATLAB? ›

The Deleted Files folder on MATLAB® Drive™ online holds content that you have deleted from MATLAB Drive. To restore content, select the file or folder in Deleted Files, and click Restore.

How do I delete a full directory in rmdir? ›

Deleting or removing directories (rmdir command)
  1. To empty and remove a directory, type the following: rm mydir/* mydir/.* rmdir mydir. ...
  2. To remove the /tmp/jones/demo/mydir directory and all the directories beneath it, type the following: cd /tmp rmdir -p jones/demo/mydir.

How do you remove a directory that is not empty? ›

The rmdir or rm -d command is for removing empty directories, while the rm -r command deletes non-empty directories.

How do you remove a directory with everything in it? ›

If the directory still contains files or subdirectories, the rmdir command does not remove the directory. To remove a directory and all its contents, including any subdirectories and files, use the rm command with the recursive option, -r .

How do I change the folder in MATLAB? ›

cd displays the current folder. cd newFolder changes the current folder to newFolder . Folder changes are global. Therefore, if you use cd within a function, the folder change persists after MATLAB® finishes executing the function.

How do I remove a file from a project in MATLAB? ›

In the Files view, right-click the file, and then select Remove from Project. To remove a file programmatically, use the removeFile function. Move project files or folders. Cut and paste or drag the files in the project.

How do I delete a path from $PATH? ›

We can comment or remove the last line from the /etc/profile. d/jdk. sh script to remove Java's path from the $PATH variable permanently. After removing the path from the file, when a user starts a new session, it won't have that directory in the $PATH variable.

How to check if a folder exists in MATLAB? ›

To check the existence of a file or folder, you also can use the isfolder or isfile functions. exist searches for files and folders on the search path, which can lead to unexpected results.

What is delete in MATLAB? ›

delete filename deletes the named file from the disk. The filename may include an absolute pathname or a pathname relative to the current directory. The filename may also include wildcards, ( * ). delete(h) deletes the graphics object with handle h .

How do I uninstall MATLAB files? ›

On Windows® systems, from the list of installed apps, start the interactive uninstaller and follow the prompts to uninstall MATLAB. Windows 10 — From the Windows Start menu, search for Apps & features and open the list of installed apps. Find the MATLAB release you want to uninstall and click Uninstall.

How do I remove folder properties? ›

This might work for you:
  1. left click on file/folder.
  2. right click on the selected file/folder.
  3. left click on Properties.
  4. left click on Details tab.
  5. at the bottom of the window,left click on ---Remove properties and personal information ---
Feb 10, 2023

How do I delete a package in MATLAB? ›

To uninstall toolboxes, products, support packages, or other add-ons from MATLAB®, follow these steps:
  1. On the MATLAB Home tab, in the Environment section, click Add-Ons, and then Manage Add-Ons.
  2. In the Add-On Manager window, locate the add-on, and from the ellipsis menu, click Uninstall.


Top Articles
Latest Posts
Article information

Author: Margart Wisoky

Last Updated:

Views: 5421

Rating: 4.8 / 5 (58 voted)

Reviews: 81% of readers found this page helpful

Author information

Name: Margart Wisoky

Birthday: 1993-05-13

Address: 2113 Abernathy Knoll, New Tamerafurt, CT 66893-2169

Phone: +25815234346805

Job: Central Developer

Hobby: Machining, Pottery, Rafting, Cosplaying, Jogging, Taekwondo, Scouting

Introduction: My name is Margart Wisoky, I am a gorgeous, shiny, successful, beautiful, adventurous, excited, pleasant person who loves writing and wants to share my knowledge and understanding with you.