isdir

Tests whether a name is a folder (superseded by isfolder).

Category: Programming > Files and Folders

Syntax

tf = isdir(name)

Returns true if name is an existing folder.

Description

isdir is kept for old code. It returns true for existing folders and false for files and for names that do not exist. New code should call isfolder, which also accepts string arrays and cell arrays and returns an array of the same size.

Input arguments

name
Folder name as text.

Output arguments

tf
Logical scalar.

Example

Folder, file and missing name

mkdir photos
writelines('x', 'photo.txt');
isdir('photos')
isdir('photo.txt')
isdir('missing')
Output
ans = logical
   1
ans = logical
   0
ans = logical
   0

See also

isfolder isfile exist mkdir