FUNCTION REFERENCE

dir

List file and directory information.

List file and directory information.

Syntax

entries = dir

Syntax

entries = dir(folderOrPattern)

Returns a column struct array with name, date, bytes, isdir and datenum fields. Directory listings include dot and dot-dot. Supports * and ? in the final path component; an unmatched pattern returns a 0-by-1 struct. With no output, prints names.

Example

d=tempname(pwd); mkdir(d); q=dir(d); n=numel(q); rmdir(d); n   % 2

Differences from MATLAB: Local paths only; parent-directory wildcards are rejected. Scans are limited to 10000 entries.

These are the engine’s help pages. Each page keeps its compatibility notes. File operations are unavailable in the browser.