Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

isdir

(Not recommended) Determine if input is folder on search path

isdir is not recommended. Use isfolder instead. isdir searches for folders on the search path, which can lead to unexpected results. isfolder searches for folders only on the specified path or in the current folder.

Syntax

result = isdir(folderName)

Description

example

result = isdir(folderName) returns 1 if folderName is a folder on the search path. Otherwise, isdir returns 0.

Examples

collapse all

Check if the input myfile1.txt is a folder. A result of 0 indicates that myfile1.txt is not a folder.

result = isdir('myfile1.txt')
result = logical
   0

Create the folder myfolder, and then check if myfolder is a folder. A result of 1 indicates that myfolder is a folder.

mkdir myfolder;
result = isdir('myfolder')
result = logical
   1

Get the Current Folder listing and filter out only the folders.

Create two folders, myfolder1 and myfolder2.

mkdir myfolder1
mkdir myfolder2

Get the current folder listing.

listing = dir;

Filter out only the folders.

onlyFolders = listing([listing.isdir]);
onlyFolders.name
ans = 
'.'
ans = 
'..'
ans = 
'myfolder1'
ans = 
'myfolder2'

Input Arguments

collapse all

Folder name, specified as a character vector. You can specify folderName as an absolute or relative path.

See Also

| | |

Introduced before R2006a

Was this topic helpful?