File Exchange

image thumbnail

Find and Replace in Files

version 1.1.290 (55.7 KB) by Robyn Jackey
Perform find and replace operations against a folder structure of MATLAB .m files.


Updated 20 Nov 2018

View Version History

View License

This app enables you to search for text in *.m files in a folder or folder structure. Then, you may apply replacements to the instances found. Regular expressions may optionally be used in the search text. Currently only *.m files are supported.

This code will modify multiple files within a specified folder structure. Although the app does back up the modified files to your TEMP directory, I STRONGLY RECOMMEND before using this that you also back up your code folder or commit your code to a version controlled repository.

Built by MathWorks Consulting and *requires* you to install GUI Layout Toolbox and Widgets Toolbox. This app is dependent on functionality in those toolboxes.

This app was built by MathWorks Consulting Services. To learn how a MathWorks Consultant can help improve your software development skills, please see:

Comments and Ratings (14)

Robyn Jackey

@zmi - Sorry for the warning. I'm aware and planning to make an update in the coming months, after I update Widgets Toolbox.

zmi zmi

@Robyn, please update
2020a Warning: JAVACOMPONENT will be removed in a future release. For more information see UI Alternatives for MATLAB Apps on

Robyn Jackey

@Phillip, you could drive this from the command line, yes. You may need to have the app running or add the install folder to your path (MATLAB\Add-Ons\Apps\FindandReplaceinFiles). The code could look like this:

m =; %Has various properties you can set, then call methods find() or replace().
m.FindWhat = 'abc';
m.ReplaceWith = 'y';

Phillip Corbell

Is there a way to remotely populate the find and replace fields in this app, like from an external .m file? I'm looking for a way to load a series of find and replace strings from an external list of text strings. Please advise, thanks!

Brandon Eidson

Joel Berg

Youwei Liang

Robyn Jackey

Eddie - sounds like a bug. I've added it to my task list. Thank you for reporting this.


If I double click the search box, the search item will be replaced by a different item in the history list, if I double click again, the search item will go back to the last item. Is this a feature or a bug? (I tried to use the double-click to modify a word in the search term)


Regular expression does not work for 'replace', would love to have that capability esp. used in combination with regexp in find.

per isakson

This tool fills a gap and works nicely.

However, two details with R2018a

1. "classdef Doer < handle" is depicted with spaces collapsed to one space and without the "<"
2. I would like a checkbox [Monospaced] to improve readability.

Robyn Jackey

Please note this is compatible with R2017a and newer.

Robyn Jackey

Dovud - the source code for this is all included. Just look in the add-on folder after installing this. Or rename the installer to .zip and extract it.

Dovud Nadirov

i want to create a dictionary app with matlab and i need the part of code for searching words
can you send me the code, PLEASE

MATLAB Release Compatibility
Created with R2018b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!