| Contents | Index |
rmdir(folderName)
rmdir(folderName,'s')
[status, message, messageid]
= rmdir(folderName,'s')
rmdir(folderName) removes the folder folderName from the current folder if folderName is empty. If folderName is not in the current folder, then 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 remove all subfolders and files in folderName regardless of their write permissions.
[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.
If you specify the 's' flag or include a wildcard in the folder name, MATLAB produces an error if it is unable to remove all folders. The error message lists the folder and files that MATLAB could not remove.
folderName |
String specifying the absolute or relative path name of the folder you want to remove. Default: None |
status |
Logical scalar indicating the outcome of the rmdir operation. The status value is 1 if the operation was successful and 0 if it returned an error. |
message |
String containing the warning or error message text if the operation is unsuccessful. An empty string, if the operation is successful. |
messageid |
String containing the warning or error message ID, if the operation is unsuccessful. MATLAB returns an empty string if the operation is successful. |
These examples remove an empty folder, myfiles, assuming it is in the current folder:
% Remove myfiles from the current folder:
rmdir('myfiles')
% Use the relative path to remove myfiles. Assuming
% the current folder is matlab/work and myfiles is in
% d:/matlab/work/project, type this:
rmdir('project/myfiles')
% Use the full path to remove myfiles, assuming
% the current folder is matlab/work and myfiles is in
% d:/matlab/work/project:
rmdir('d:/matlab/work/project/myfiles')This example removes the myfiles folder and its contents, assuming myfiles is in the current folder:
rmdir('myfiles','s')This example unsuccessfully attempts to remove the myfiles folder and its contents. It directs MATLAB to display the results.
[stat, mess, id]=rmdir('myfiles')
MATLAB returns:
stat =
0
mess =
No directories were removed.
id =
MATLAB:RMDIR:NoDirectoriesRemovedThis example successfully removes the myfiles folder and its contents. It directs MATLAB to display the results.
[stat, mess]=rmdir('myfiles','s')MATLAB returns:
stat =
1
mess =
''Open the Current Folder browser by running filebrowser. Then, in the Current Folder browser, right-click the folder name and select Delete from the context menu.
cd | copyfile | delete | dir | fileattrib | filebrowser | mkdir | movefile

Explore how to use MATLAB to make advancements in engineering and science.
| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |