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

movefile — Move or rename files, directories, or wildcard matches.

movefile changes filesystem paths and returns status with optional diagnostics.

Syntax

[status, msg, msgID] = movefile(source, destination)
[status, msg, msgID] = movefile(source, destination, flag)

Inputs

source
Type
StringScalar
Required
Yes
Description
Source file, directory, or wildcard pattern.
destination
Type
StringScalar
Required
Yes
Description
Destination file or directory path.
flag
Type
StringScalar
Required
Yes
Default
'f'
Description
Case-insensitive 'f' flag that permits replacement of an existing target.
NameTypeRequiredDefaultDescription
sourceStringScalarYes—Source file, directory, or wildcard pattern.
destinationStringScalarYes—Destination file or directory path.
flagStringScalarYes'f'Case-insensitive 'f' flag that permits replacement of an existing target.

Returns

status
Type
NumericScalar
Description
Double scalar 1 after success or 0 after an operational failure.
msg
Type
StringScalar
Description
Character-row diagnostic, empty after success.
msgID
Type
StringScalar
Description
Character-row diagnostic identifier, empty after success.
NameTypeDescription
statusNumericScalarDouble scalar 1 after success or 0 after an operational failure.
msgStringScalarCharacter-row diagnostic, empty after success.
msgIDStringScalarCharacter-row diagnostic identifier, empty after success.

Returned values from movefile depend on how many outputs the caller requests.

Errors

RunMat:movefile:NotEnoughInputs
When
Fewer than two inputs are provided.
Message
movefile: not enough input arguments
RunMat:movefile:TooManyInputs
When
More than three inputs are provided.
Message
movefile: too many input arguments
RunMat:movefile:SourceArgType
When
Source is not a character row or string scalar.
Message
movefile: source must be a character vector or string scalar
IdentifierWhenMessage
RunMat:movefile:NotEnoughInputsFewer than two inputs are provided.movefile: not enough input arguments
RunMat:movefile:TooManyInputsMore than three inputs are provided.movefile: too many input arguments
RunMat:movefile:SourceArgTypeSource is not a character row or string scalar.movefile: source must be a character vector or string scalar
RunMat:movefile:DestinationArgTypeDestination is not a character row or string scalar.movefile: destination must be a character vector or string scalar
RunMat:movefile:FlagArgTypeThe optional flag is not 'f'.movefile: flag must be the character 'f' supplied as a char vector or string scalar
RunMat:movefile:OSErrorThe filesystem move fails.movefile: unable to move
RunMat:movefile:FileDoesNotExistThe source or wildcard match does not exist.movefile: source not found
RunMat:movefile:DestinationExistsThe target exists without the force flag.movefile: destination already exists
RunMat:movefile:DestinationNotFoundA wildcard transfer targets a missing directory.movefile: destination folder not found
RunMat:movefile:DestinationNotDirectoryA wildcard transfer targets a non-directory.movefile: destination is not a directory
RunMat:movefile:EmptySourceThe source path is empty.Source file or folder name must not be empty.
RunMat:movefile:EmptyDestinationThe destination path is empty.Destination file or folder name must not be empty.
RunMat:movefile:InvalidPatternThe source wildcard pattern is invalid.movefile: invalid source pattern

Move and rename files

movefile(source, destination) renames one file or directory or moves it to another directory. A source containing wildcards moves every match into an existing destination directory.

Pass 'f' as the third argument to replace a compatible existing destination. Without that flag, an existing target is preserved and the operation reports failure. Replacement uses the filesystem provider's rename operation; it does not delete the destination first. Incompatible types, nonempty destination directories, unsupported providers, and cross-filesystem moves can fail while preserving the source and destination.

Results and execution

status is a double scalar: 1 after success and 0 after an operational failure. msg and msgID are empty character rows after success and describe a failure otherwise. Without outputs, an operational failure raises an error. Invalid argument types and malformed flags raise an error before filesystem access.

Paths accept character rows and scalar strings. Relative paths use the current folder and a leading ~ expands through the active environment. The operation runs through the host or browser filesystem service. Numeric and provider-resident path values reject without a device transfer; no accelerator kernel is used.

The active filesystem provider defines cross-volume behavior and metadata preservation. If its rename operation cannot move between two storage volumes, movefile returns status 0 with the provider error and leaves recovery to the caller.

Cancellation is checked before filesystem mutation and between wildcard entries. Wildcard moves are sequential and nontransactional: files completed before an error or cancellation remain moved.

Examples

Rename a file

root = tempname();
mkdir(root);
source = fullfile(root, 'results.txt');
target = fullfile(root, 'archive.txt');
fid = fopen(source, 'w'); fclose(fid);
status = movefile(source, target);
sourceAfter = exist(source, 'file');
targetAfter = exist(target, 'file');
rmdir(root, 's');

Expected output:

status is double 1, the source is absent, and the target exists

Move a file into a directory

root = tempname();
mkdir(root);
mkdir(root, 'reports');
source = fullfile(root, 'summary.txt');
fid = fopen(source, 'w'); fclose(fid);
status = movefile(source, fullfile(root, 'reports'));
moved = exist(fullfile(root, 'reports', 'summary.txt'), 'file');
rmdir(root, 's');

Expected output:

the source name is retained inside the destination directory

Replace an existing file

root = tempname();
mkdir(root);
source = fullfile(root, 'draft.txt');
target = fullfile(root, 'final.txt');
fid = fopen(source, 'w'); fclose(fid);
fid = fopen(target, 'w'); fclose(fid);
[status, msg, msgID] = movefile(source, target, 'f');
rmdir(root, 's');

Expected output:

status is 1 and both diagnostic character rows are empty

Move every wildcard match

root = tempname();
mkdir(root);
mkdir(root, 'data');
fid = fopen(fullfile(root, 'a.log'), 'w'); fclose(fid);
fid = fopen(fullfile(root, 'b.log'), 'w'); fclose(fid);
status = movefile(fullfile(root, '*.log'), fullfile(root, 'data'));
first = exist(fullfile(root, 'data', 'a.log'), 'file');
second = exist(fullfile(root, 'data', 'b.log'), 'file');
rmdir(root, 's');

Expected output:

both matching files are moved

Inspect a missing-source result

root = tempname();
mkdir(root);
[status, msg, msgID] = movefile(fullfile(root, 'missing.txt'), fullfile(root, 'dest.txt'));
rmdir(root);

Expected output:

status is 0 and the diagnostic rows identify the failure

Leave a file in place when both paths match

root = tempname();
mkdir(root);
source = fullfile(root, 'stable.txt');
fid = fopen(source, 'w'); fclose(fid);
status = movefile(source, source);
stillPresent = exist(source, 'file');
rmdir(root, 's');

Expected output:

status is 1 and the file remains at the same path

Using movefile with coding agents

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

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

FAQ

How do I replace an existing target?⌄

Pass 'f' as the third argument. Without it, movefile leaves the existing target unchanged and returns status 0.

Can movefile move several files?⌄

Yes. Use a wildcard source and an existing destination directory. Every match is planned before the first move begins. The moves execute in sequence, not as one transaction; an error can leave earlier matches already moved.

Can movefile cross storage volumes?⌄

Only when the active filesystem provider supports that rename. An unsupported cross-volume move returns status 0 and provider diagnostics.

Can movefile run on a GPU?⌄

No. Filesystem access is a host-service operation, and path inputs must be host text.

Related Io functions

Repl Fs

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 · 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 movefile is executed, line by line, in Rust.

  • View the source for movefile 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
  • Move and rename files
  • Results and execution
  • Examples
  • Rename a file
  • Move a file into a directory
  • Replace an existing file
  • Move every wildcard match
  • Inspect a missing-source result
  • Leave a file in place when both paths match
  • Using movefile 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