rmdir

Removes the directory dir.

Syntax

rmdir dir

rmdir(dir)

rmdir(dir, 's')

[status, msg1, msg2] = rmdir(dir)

Inputs

dir
Name of the directory to be removed. It needs to be empty if option s is not specified.
Type: string
s
Additional option which specifies if the files and sub-directories under dir should be deleted.

Outputs

status
Returns 1 if successful; returns 0 if not successful.
msg1
If status is 1 (successful), msg1 is empty. If status is 0 (unsuccessful), msg1 contains an error mesage.
msg2
If status is 1 (successful), msg2 is empty. If status is 0 (unsuccessful), msg2 returns the command name 'rmdir'.

Examples

Simple rmdir successful example:
rmdir('C:/testdirectory')
ans = 1
Simple rmdir unsuccessful example with fail outputs:
[status, msg1, msg2] = rmdir('C:/testdirectory')
status = 0
msg1 = Problem removing directory
msg2 = rmdir
Remove a non-empty directory, along with all contents:
rmdir('C:/nonempty_testdirectory', 's')
ans = 1