isfolder

Tests whether a name is an existing folder.

Category: Programming > Files and Folders

Syntax

tf = isfolder(name)

Returns true if name is a folder.

Description

isfolder is true for existing folders and false for files and for names that do not exist. Relative names are resolved against the current folder, and '.' is always a folder. It does not search the path.

With a cell array or string array it tests every name and returns an array of the same size.

Input arguments

name
Folder name as text, a string array, or a cell array of names.

Output arguments

tf
Logical array with one entry per name.

Example

Testing folders

mkdir reports
isfolder('reports')
isfolder({'.', 'reports', 'nope'})
Output
ans = logical
   1
ans = 1×3 logical array

   1   1   0

See also

isfile isdir exist mkdir