Find Files: exclude directories

I use "Find Files" a lot to find .m files with a particular string, but 99%+ of the time I want to search only the files I've created myself. The search takes 10x as long because my only option other than guessing which directory to search seems to be to choose "Entire Matlab path", which means I search through every subdirectory in the Mathworks install. Is there a way to exclude certain directories, or to explicitly choose "Don't search Mathworks code"? That would really speed things up for me.

6 Comments

If you put all of your code under a common folder, then search that folder?
For example all of the things that I hack together for these questions, I put into my MATLAB folder, using a hierarchy based on the Question number, so I only need to search from there downwards.
dpb
dpb on 20 Nov 2020
Edited: dpb on 20 Nov 2020
I've never used the "Find Files" button but just do a dir() for the pattern at command line. That covers the MATLABPATH but generally is still pretty quick.
If I do want to get more specific, since I use the JPSoft command shell instead of the MS CMD with its greatly enhanced builtin DIR command, I can easily just bang a DIR command to the OS for the purpose. I'm not positive what features CMD has on its version (presuming Windows, of course).
Would seem like what you're asking for would be a reasonable enhancement request, though, for the builtin tool.
What has alrways bugged me the most is that dir() isn't able to use all the features of the OS in its wildcards or other switches. :(
I guess my phrasing was unclear: I am searching for a string within the body of a file, not within the name of the file, so dir() doesn't help me.
It's true that I could put all my code in one folder and then search that, but that would be a complete rearrangement of my entire workflow and organization (which is based around storing things by project rather than code type, making it easier to share an entire project's resources with another researcher). So I'm hoping for a solution that enhances my current work rather than forcing me to adapt to the limitations of the tool.
I also frequently find it useful to use the "Find Files" button, and echo the OP's desire to further filter the search path to get it to be more responsive. If no one has an answer for this one, it would be a good one for the developers to please put on a wish list
Oh. Indeed I did misunderstand. See, told you never used the builtin! :)
For that I do essentially the same that I outlined above however, except dispatch grep through the OS.
Altho I admit I do this on a much less frequent interval than looking for files themselves. Then again, I'm not building large applications in MATLAB, either; but I did do such searches much more frequently with Fortran source code while still actively consulting so I grok the need/idea

Sign in to comment.

Answers (0)

Categories

Products

Release

R2020b

Tags

Asked:

on 20 Nov 2020

Commented:

dpb
on 20 Nov 2020

Community Treasure Hunt

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

Start Hunting!