File Exchange

image thumbnail

FAST, PROGRAMMATIC string searching in directories of MATLAB code files

version 1.4.0.1 (5.45 KB) by Brett Shoelson
VERY FAST Command-Line searching for text contained in MATLAB code files.

2 Downloads

Updated 01 Sep 2016

View License

Editor's Note: This file was selected as MATLAB Central Pick of the Week

Pre-analyze directories of MATLAB code to create searchable text files for very fast scanning for strings across multiple files.
The MathWorks 'Find Files' interface allows interactive searching for text in MATLAB files. |findInM| (in conjunction with its companion |collectCode|) allows you to search programmatically (i.e., from within a script or function, or at the Command Line), and can be much faster than any other method I've seen.
On first use, or when a New collection is requested, the user will be prompted to select a top-level directory and to indicate whether or not to recurse, and a new code collection will be created and stored. This will allow for very fast subsequent searches.
Comments/suggestions/collaborations welcome.

Comments and Ratings (4)

Brett Shoelson

New version (1/5/15) fixes a few minor issues, and removes the 'userpath' function that Jan (rightfully) questioned.

Brett Shoelson

@Jan: Absolutely great question-indeed one that I asked too! Currently, because the userpath function lives in the local toolbox (which can be modified by users), it is treated carefully and distinctly by the matlab.codetools.requiredFilesAndProducts function. If one uses userpath, it is recognized as a dependency by requiredFilesAndProducts. In the Apps packager, there is not currently a way for me to remove auto-detected dependencies. I'm hoping we can figure out a better way to deal with that...but I'm stuck packaging it with my submission at the moment. Very perceptive question! Brett

Jan

Jan (view profile)

"userpath" is built-in Matlab function. Why is it included in this submission?

Chang hsiung

good job!!!

Updates

1.4.0.1

Updated license

1.4.0.0

(Once again, removed userpath).

1.3.0.0

Added special handling for 2-input case:
a = findInM(searchstring,collection); AND, added "Current-Directory" search:
a = findInM(searchstring,'pwd').

1.2.0.0

I made some general improvements, and allowed for sorting by date or size. Better auto-naming of code collections. Also added a screen shot.

1.1.0.0

Better naming convention

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

Discover Live Editor

Create scripts with code, output, and formatted text in a single executable document.


Learn About Live Editor