| MATLAB Function Reference | ![]() |
Graphical Interface
As an alternative to the mkdir function, you can click the New folder button
in the Current Directory browser to add a directory.
Syntax
mkdir('dirname')mkdir('parentdir','dirname')status = mkdir(...,'dirname') [status,message,messageid] = mkdir(...,'dirname')
Description
mkdir(' creates the directory dirname')
dirname in the current directory, if dirname represents a relative path. Otherwise, dirname represents an absolute path and mkdir attempts to create the absolute directory dirname in the root of the current volume. An absolute path starts with any one of the following: a Windows drive letter, a UNC path '\\' string, or a UNIX '/' character.
mkdir(' creates the directory parentdir','dirname')
dirname in the existing directory parentdir, where parentdir is an absolute or relative pathname.
status = mkdir(...,'dirname')
creates the specified directory and returns a status of logical 1 if the operation was successful, or logical 0 if unsuccessful.
[status,message,messageid] = mkdir(...,'dirname')
creates the specified directory, and returns status, message string, and MATLAB error message ID. the value given to status is logical 1 for success and logical 0 for error.
See the help for error and lasterr for more information.)
Create a Subdirectory in Current Directory
To create a subdirectory in the current directory called newdir, type
Create a Subdirectory in Specified Parent Directory
To create a subdirectory called newdir in the directory testdata, which is at the same level as the current directory, type
Return Status When Creating Directory
In this example, the first attempt to create newdir succeeds, returning a status of 1, and no error or warning message or message identifier:
If you attempt to create the same directory again, mkdir again returns a success status, and also a warning and message identifier informing you that the directory already existed:
[s,mess,messid] = mkdir('../testdata','newdir') s = 1 mess = Directory "newdir" already exists. messid = MATLAB:MKDIR:DirectoryExists
See Also
copyfile, cd, dir, fileattrib, filebrowser, fileparts, ls, mfilename, movefile, rmdir
| mislocked | mkdir (ftp) | ![]() |
© 1994-2005 The MathWorks, Inc.