mkdir

Creates the directory newdir in the current working directory by default.

Syntax

[R1, R2] = mkdir(newdir)

[R1, R2] = mkdir(parentdir, newdir)

Inputs

newdir
Name of new directory to create (absolute or relative path). If nargin is 2, newdir is the second argument.
Type: char | string
parentdir
Name of parent directory within which to create newdir. If nargin is 2, this is the first argument.
Type: char | string

Outputs

R1
Returns 1 if successful; returns 0 if not successful.
Type: logical
R2
Returns an error message if the command is not successful (R1 is 0).
Type: char | string

Examples

mkdir('Test')
ans = 1
Input with parent:
mkdir('C:','Test')
ans = 1
Repeat above test to produce and capture error:
[R1, R2] = mkdir('C:','Test')
R1 = 0
R2 = directory exists

Comments

If the variable parentdir is provided, the command creates the directory newdir in the parent directory.