| 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 rmdir function, use the delete feature in the Current Folder browser.
rmdir('folderName')
rmdir('folderName','s')
[status, message, messageid] = rmdir('folderName','s')
rmdir('folderName') removes the folder folderName from the current folder, where folderName is empty. If folderName is not in the current folder, specify the relative path or the full path for folderName.
rmdir('folderName','s') removes the folder folderName and its contents from the current folder. With the 's' option, rmdir attempts to removes 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, message, messageid] = rmdir('folderName','s') removes the folder folderName and its contents from the current folder, returning the status, a message, and the MATLAB message ID. Here, status is 1 for success and is 0 for error. message, messageid, and the s input argument are optional.
When attempting to remove multiple folders, either by including a wildcard in the folder name or by specifying the 's' flag in rmdir, MATLAB produces an error if it is unable to remove all folders as expected. The error message lists the folder and files that MATLAB could not remove.
Remove myfiles from the current folder, where myfiles is empty:
rmdir('myfiles')If the current folder is matlab/work, and myfiles is in d:/matlab/work/project/, use the relative path to remove myfiles:
rmdir('project/myfiles')If the current folder is matlab/work, and myfiles is in d:/matlab/work/project/, use the full path to remove myfiles:
rmdir('d:/matlab/work/project/myfiles')Remove myfiles, its subfolders, and all files in the folders, assuming myfiles is in the current folder:
rmdir('myfiles','s')Remove myfiles from the current folder, where myfiles is not empty, and return the results:
[stat, mess, id]=rmdir('myfiles')MATLAB returns:
stat =
0
mess =
The directory is not empty.
id =
MATLAB:RMDIR:OSErrorRemove myfiles and its contents using the s option, which is required for non-empty folders, and return the results:
[stat, mess]=rmdir('myfiles','s')MATLAB returns:
stat =
1
mess =
''catch, cd, copyfile, delete, dir, fileattrib, filebrowser, MException, mkdir, movefile, try
![]() | rmappdata | rmdir (ftp) | ![]() |

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 |