MATLAB Function Reference Previous page   Next Page
mkdir

Make new directory

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

Description

mkdir('dirname') creates the directory 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('parentdir','dirname') creates the directory 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.)

Examples

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:

See Also

copyfile, cd, dir, fileattrib, filebrowser, fileparts, ls, mfilename, movefile, rmdir


Previous page  mislocked mkdir (ftp) Next page

© 1994-2005 The MathWorks, Inc.