RunMat
  • Pricing
RunMat
GitHub
GitHub
Sign inTry in browser
DesktopRuntimePhysicsCADAdministrationAgent

Get RunMat updates

New releases, guides and examples.

Product+
  • Runtime
  • GPU
  • Parallel
  • Compile
  • Interop and MEX
  • Simulation
  • MCAD
  • ECAD
  • Enterprise
  • AI integrations
  • Pricing
  • Download
Math+
  • Signal processing
  • Linear algebra
  • Statistics
  • Curve fitting
  • Differential equations
  • Control systems
  • Optimization
  • Finance
  • Data and tables
  • Plotting
Physics+
  • Simulation overview
  • Structural
  • Thermal
  • Electromagnetic
  • Joule heating
  • Thermal stress
  • Acoustics
  • Fluid flow
  • Conjugate heat transfer
  • Fluid–structure
  • What is FEA
Industries+
  • Aerospace
  • Automotive and transportation
  • Defense
  • Electronics and semiconductors
  • Energy
  • Industrial machinery
  • Life sciences
  • Quantitative finance
Learn+
  • Guides
  • Docs
  • Function reference
  • Language reference
  • Migration guide
  • Changelog
  • MATLAB Online
  • MATLAB AI agent
  • For students
Compare+
  • RunMat vs MATLAB
  • RunMat vs Ansys
  • RunMat vs SOLIDWORKS
  • RunMat vs Altium
  • RunMat vs Cadence
  • RunMat vs COMSOL
  • RunMat vs Python
  • RunMat vs Julia
  • RunMat vs Physics AI
  • RunMat vs Octave
  • Benchmarks
  • MATLAB alternatives
  • All comparisons
Company+
  • About
  • Blog
  • Contact
  • Source code↗
  • License
  • Privacy
  • Terms

Product

  • Runtime
  • GPU
  • Parallel
  • Compile
  • Interop and MEX
  • Simulation
  • MCAD
  • ECAD
  • Enterprise
  • AI integrations
  • Pricing
  • Download

Math

  • Signal processing
  • Linear algebra
  • Statistics
  • Curve fitting
  • Differential equations
  • Control systems
  • Optimization
  • Finance
  • Data and tables
  • Plotting

Physics

  • Simulation overview
  • Structural
  • Thermal
  • Electromagnetic
  • Joule heating
  • Thermal stress
  • Acoustics
  • Fluid flow
  • Conjugate heat transfer
  • Fluid–structure
  • What is FEA

Industries

  • Aerospace
  • Automotive and transportation
  • Defense
  • Electronics and semiconductors
  • Energy
  • Industrial machinery
  • Life sciences
  • Quantitative finance

Learn

  • Guides
  • Docs
  • Function reference
  • Language reference
  • Migration guide
  • Changelog
  • MATLAB Online
  • MATLAB AI agent
  • For students

Compare

  • RunMat vs MATLAB
  • RunMat vs Ansys
  • RunMat vs SOLIDWORKS
  • RunMat vs Altium
  • RunMat vs Cadence
  • RunMat vs COMSOL
  • RunMat vs Python
  • RunMat vs Julia
  • RunMat vs Physics AI
  • RunMat vs Octave
  • Benchmarks
  • MATLAB alternatives
  • All comparisons

Company

  • About
  • Blog
  • Contact
  • Source code↗
  • License
  • Privacy
  • Terms
GitHubXLinkedIn

© Dystr, Inc. · RunMat v0.7.1, Nov 17, 2026

RunMat® is a registered trademark of Dystr, Inc. MATLAB® is a registered trademark of The MathWorks, Inc. RunMat is not affiliated with, endorsed by, or sponsored by The MathWorks, Inc.

/
See all docs
Builtin Reference
    • addpath
    • cd
    • copyfile
    • delete
    • dir
    • exist
    • fileattrib
    • fileparts
    • filesep
    • fullfile
    • genpath
    • getenv
    • getpref
    • isenv
    • isfile
    • isfolder
    • ispref
    • ls
    • matlabroot
    • memmapfile
    • memmapfile.subsasgn
    • memmapfile.subsref
    • mkdir
    • movefile
    • open
    • opentoline
    • path
    • pathsep
    • pcode
    • pwd
    • readstruct
    • rehash
    • restoredefaultpath
    • rmdir
    • rmpath
    • run
    • savepath
    • setenv
    • setpref
    • system
    • tempdir
    • tempname
    • uigetdir
    • uigetfile
    • uiputfile
    • unsetenv
    • userpath
    • what
    • winqueryreg
    • xmlread
    • xmlwrite

dir — List files and folders with metadata.

dir lists local files and folders and returns their names, containing folders, modification times, sizes, and directory flags.

Syntax

listing = dir()
listing = dir(name)
listing = dir(folder, pattern)

Inputs

name
Type
StringScalar
Required
Yes
Description
File, folder, or wildcard path as a character vector or string scalar.
pattern
Type
StringScalar
Required
Yes
Description
RunMat-only wildcard pattern evaluated within the first folder input.
NameTypeRequiredDefaultDescription
nameStringScalarYes—File, folder, or wildcard path as a character vector or string scalar.
patternStringScalarYes—RunMat-only wildcard pattern evaluated within the first folder input.

Returns

listing
Type
Any
Description
Column struct array with name, folder, date, bytes, isdir, and datenum fields.
NameTypeDescription
listingAnyColumn struct array with name, folder, date, bytes, isdir, and datenum fields.

Errors

RunMat:dir:InvalidArity
When
More than two inputs are supplied.
Message
dir: too many input arguments
RunMat:dir:InvalidName
When
The name input is not a character vector or string scalar.
Message
dir: name must be a character vector or string scalar
RunMat:dir:InvalidFolder
When
The first input in the two-input form is not a character vector or string scalar.
Message
dir: folder must be a character vector or string scalar
IdentifierWhenMessage
RunMat:dir:InvalidArityMore than two inputs are supplied.dir: too many input arguments
RunMat:dir:InvalidNameThe name input is not a character vector or string scalar.dir: name must be a character vector or string scalar
RunMat:dir:InvalidFolderThe first input in the two-input form is not a character vector or string scalar.dir: folder must be a character vector or string scalar
RunMat:dir:InvalidPatternThe second input is not a character vector or string scalar.dir: pattern must be a character vector or string scalar
RunMat:dir:FolderWildcardThe two-input form uses wildcard characters in its folder input.dir: folder input must not contain wildcard characters

Paths and patterns

With no input, dir lists the current folder. A file path returns one metadata record; a folder path lists that folder; and *, ?, and supported ** components select matching entries. Relative paths use the current folder and a leading ~ uses the active environment.

dir(folder, pattern) keeps the base folder and wildcard separate. This two-input convenience form is available in RunMat mode; use dir(fullfile(folder, pattern)) for source that must remain within the MATLAB-compatible subset.

Returned metadata

The column result has name, folder, date, bytes, isdir, and datenum fields. folder is the absolute containing folder, bytes is a double byte count, isdir is logical, and the date fields describe the last observed modification time.

A folder listing includes . and ... A missing well-formed path or wildcard with no matches returns an empty result. Results use platform-aware name ordering.

Execution boundary

Directory enumeration and metadata lookup use RunMat's filesystem service on native and browser/WASM targets. Remote HTTP, HTTPS, authenticated, FTP, and SFTP locations are not currently resolved by this builtin.

Paths must be host text. Numeric and provider-resident inputs reject before provider or filesystem access; dir is not an accelerator or fusion operation.

Examples

List the current folder

root = tempname();
mkdir(root);
fid = fopen(fullfile(root, 'current.txt'), 'w'); fclose(fid);
start = cd(root);
listing = dir;
cd(start);
found = false;
for k = 1:numel(listing)
    found = found || strcmp(listing(k).name, 'current.txt');
end
rmdir(root, 's');

Expected output:

listing includes current.txt

List a folder

root = tempname();
mkdir(root);
fid = fopen(fullfile(root, 'alpha.txt'), 'w'); fclose(fid);
mkdir(fullfile(root, 'nested'));
listing = dir(root);
found_alpha = false;
found_nested = false;
for k = 1:numel(listing)
    found_alpha = found_alpha || strcmp(listing(k).name, 'alpha.txt');
    found_nested = found_nested || strcmp(listing(k).name, 'nested');
end
rmdir(root, 's');

Expected output:

listing includes alpha.txt and nested

Inspect one file

root = tempname();
mkdir(root);
file = fullfile(root, 'payload.bin');
fid = fopen(file, 'w'); fwrite(fid, uint8([1 2 3])); fclose(fid);
info = dir(file);
rmdir(root, 's');

Expected output:

info describes payload.bin

Match a wildcard

root = tempname();
mkdir(root);
fid = fopen(fullfile(root, 'first.m'), 'w'); fclose(fid);
fid = fopen(fullfile(root, 'notes.txt'), 'w'); fclose(fid);
listing = dir(fullfile(root, '*.m'));
rmdir(root, 's');

Expected output:

listing contains first.m

Match within a folder

root = tempname();
mkdir(root);
fid = fopen(fullfile(root, 'one.csv'), 'w'); fclose(fid);
fid = fopen(fullfile(root, 'two.txt'), 'w'); fclose(fid);
listing = dir(root, '*.csv');
rmdir(root, 's');

Expected output:

listing contains one.csv

Handle no matches

root = tempname();
mkdir(root);
listing = dir(fullfile(root, '*.missing'));
rmdir(root);

Expected output:

listing is empty

Read metadata fields

root = tempname();
mkdir(root);
fid = fopen(fullfile(root, 'sample.dat'), 'w'); fclose(fid);
info = dir(fullfile(root, 'sample.dat'));
rmdir(root, 's');

Expected output:

info contains the standard metadata fields

Using dir with coding agents

Open a RunMat example with live inputs, then ask the agent to explain how dir changes the result.

Run a small dir example, explain the result, then change one input and compare the output.

FAQ

Which path values can I pass to dir?⌄

Use a character vector or string scalar containing a local file, folder, or wildcard path. Numeric values, cells, character matrices, and nonscalar string arrays are rejected before filesystem access.

Why do folder listings contain . and ..?⌄

The compatible folder-listing form includes the current-folder and parent-folder entries. Wildcard results contain only entries matched by the pattern.

Does dir support recursive wildcards?⌄

The ** form traverses subfolders when it appears as a complete path component. Ordinary * and ? patterns match within one directory level.

Does dir support remote URLs?⌄

Not yet. This implementation reads through RunMat's native or browser filesystem service and currently resolves local filesystem paths only.

Can dir inspect a gpuArray path?⌄

No. Paths are host text. Numeric and provider-resident values are rejected without an implicit device transfer.

Related Io functions

Repl Fs

addpath · cd · copyfile · delete · exist · fileattrib · fileparts · filesep · fullfile · genpath · getenv · getpref · isenv · isfile · isfolder · ispref · ls · matlabroot · memmapfile · memmapfile.subsasgn · memmapfile.subsref · mkdir · movefile · open · opentoline · path · pathsep · pcode · pwd · readstruct · rehash · restoredefaultpath · rmdir · rmpath · run · savepath · setenv · setpref · system · tempdir · tempname · uigetdir · uigetfile · uiputfile · unsetenv · userpath · what · winqueryreg · xmlread · xmlwrite

Net

accept · read · readline · tcpclient · tcpserver · write

Tabular

arrayDatastore · csvread · csvwrite · detectImportOptions · dlmread · dlmwrite · fileDatastore · getvaropts · parquetDatastore · parquetinfo · parquetread · readcell · readmatrix · readtable · readtimetable · setvaropts · setvartype · spreadsheetImportOptions · writecell · writematrix · writetable · writetimetable · xlsread · xlswrite

Audio

audioinfo · audioread

Io

clc · diary · disp · display · format · input

Data

commit · data.copy · data.create · data.delete · data.exists · data.export · data.import · data.inspect · data.list · data.move · data.open · DataArray.chunk_shape · DataArray.codec · DataArray.dtype · DataArray.fill · DataArray.name · DataArray.rank · DataArray.read · DataArray.resize · DataArray.shape · DataArray.write · Dataset.array · Dataset.arrays · Dataset.attrs · Dataset.begin · Dataset.get_attr · Dataset.has_array · Dataset.id · Dataset.path · Dataset.refresh · Dataset.set_attr · Dataset.set_attrs · Dataset.snapshot · Dataset.version · DataTransaction.abort · DataTransaction.commit · DataTransaction.create_array · DataTransaction.delete_array · DataTransaction.fill · DataTransaction.id · DataTransaction.resize · DataTransaction.set_attr · DataTransaction.set_attrs · DataTransaction.status · DataTransaction.write

Filetext

fclose · feof · fgetl · fgets · fileread · filewrite · fopen · fprintf · fread · frewind · fwrite · readlines · writelines

Archive

gunzip · gzip · unzip

Hdf5

h5disp · h5info · h5read · h5write · h5writeatt · hdf5info · hdf5read · hdf5write

Import

importdata · textscan

Json

jsondecode · jsonencode

Mat

load · matfile · matlab.io.MatFile.subsasgn · matlab.io.MatFile.subsref · save

Http

sendmail · urldecode · urlencode · weboptions · webread · websave · webwrite

Source you can read

Every RunMat function's source is public. Read exactly how dir is executed, line by line, in Rust.

  • View the source for dir in Rust on GitHub
  • Learn how the RunMat runtime works
  • Found a bug? Open an issue with a minimal reproduction.

About RunMat

RunMat is a runtime that executes MATLAB-syntax code fast on any GPU. The runtime is free for individuals, including freelancers; students and faculty at an academic institution, for teaching or research there; contributors to an open-source project, for work on that project; organizations with 250 or fewer people and US$10M or less in annual revenue; and anyone, for non-production use. See runmat.com/license.

  • RunMat automatically optimizes your math for GPU execution on Apple, Nvidia, and AMD hardware. No code changes needed. Simulations that took hours now take minutes.
  • Start running code in seconds. RunMat runs in the browser, on the desktop, or from the CLI. No license server, no IT ticket.

Getting started · Benchmarks · Pricing

Download RunMat

Download RunMat for full performance, or use RunMat in your browser for zero setup.

Download RunMatOpen Sandbox
On this page
  • Syntax
  • Inputs
  • Returns
  • Errors
  • Paths and patterns
  • Returned metadata
  • Execution boundary
  • Examples
  • List the current folder
  • List a folder
  • Inspect one file
  • Match a wildcard
  • Match within a folder
  • Handle no matches
  • Read metadata fields
  • Using dir with coding agents
  • FAQ
  • Related Io functions
  • Repl Fs
  • Net
  • Tabular
  • Audio
  • Io
  • Data
  • Filetext
  • Archive
  • Hdf5
  • Import
  • Json
  • Mat
  • Http
  • Source you can read
  • About RunMat