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.

8 Downloads

Updated 20 Nov 2018

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.
https://www.mathworks.com/matlabcentral/fileexchange/47982-gui-layout-toolbox
https://www.mathworks.com/matlabcentral/fileexchange/66235-widgets-toolbox

This app was built by MathWorks Consulting Services. To learn how a MathWorks Consultant can help improve your software development skills, please see:
https://www.mathworks.com/services/consulting/proven-solutions/software-development-with-matlab.html
https://www.mathworks.com/services/consulting.html

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 mathworks.com

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 = csg.app.FindReplaceFiles.Model; %Has various properties you can set, then call methods find() or replace().
m.FindWhat = 'abc';
m.find();
m.ReplaceWith = 'y';
m.replace();

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.

Eddie

Hello,
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)

Eddie

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

Hello
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
physic_96@mail.ru

Updates

1.1.290

Bugfix for special characters. Switched code font to Monospaced.

1.0.156.0

Bugfix: corrected the hyperlink location where the original files are backed up

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

Inspired by: GUI Layout Toolbox, Widgets Toolbox