Main Content

isfile

Determine if input is file

Description

result = isfile(fileName) returns 1 if fileName is a file located on the specified path or in the current folder. Otherwise, isfile returns 0.

Examples

collapse all

Check if the input myfile1.txt is a file. A result of 1 indicates that myfile1.txt is a file.

result = isfile('myfile1.txt')
result = logical
   1

Create the folder myfolder, then check if myfolder is a file. A result of 0 indicates that myfolder is not a file.

mkdir myfolder;
result = isfile('myfolder')
result = logical
   0

Check if the inputs myfile1.txt and myfolder are files. A result of [1 0] indicates that myfile1.txt is a file and myfolder is not a file.

result = isfile(["myfile1.txt", "myfolder"])
result = 1×2 logical array
   1   0

Input Arguments

collapse all

File name, specified as a string array, character vector, or cell array of character vectors. For a local file, fileName can include a relative path, but the relative path must be in the current folder. Otherwise, fileName must include a full path. If the file is stored at a remote location, then fileName must contain a full path specified as a uniform resource locator (URL). For more information, see Work with Remote Data.

Extended Capabilities

Version History

Introduced in R2017b