dir
List folder contents
Description
dir
lists files and folders in the current
folder.
dir
lists files and folders
that match name
name
. When name
is a folder,
dir
lists the contents of the folder. Use wildcards
*
and **
to match patterns. For
example, dir *.mlx
lists all files with the extension
.mlx
, and dir **
includes files in all
subfolders.
Examples
Input Arguments
Output Arguments
Limitations
MATLAB® does not support internet URLs that require authentication.
MATLAB Online™ supports internet URLs associated with Microsoft OneDrive™ files and folders, while the installed version of MATLAB supports only local OneDrive files.
Tips
If
dir
cannot query a file, it returns these default values in the output structure.date: '' bytes: [] isdir: 0 datenum: []
This issue most commonly occurs when querying a symbolic link pointing to a moved, removed, or renamed target. To exclude these invalid entries, you can convert the structure to a table and remove the rows with empty values.
listing = struct2table(dir); listing(isempty(listing.bytes),:) = [];
To obtain a list of available drives on Microsoft Windows platforms, use the DOS
net use
command.dos("net use")