Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Function alternative to find files dialog

Subject: Function alternative to find files dialog

From: Richard Crozier

Date: 19 Apr, 2012 11:17:08

Message: 1 of 5

Does anyone know of a function alternative to the 'Find Files' dialog in Matlab?

I would like to use to output of this dialog to search and replace strings in the located files. Therefore all I really need is the file locations containing the search text. Ideally I would like a cell array of all these locations to operate on.

Subject: Function alternative to find files dialog

From: Nasser M. Abbasi

Date: 19 Apr, 2012 11:28:22

Message: 2 of 5

On 4/19/2012 6:17 AM, Richard Crozier wrote:
> Does anyone know of a function alternative to the 'Find Files' dialog in Matlab?
>
> I would like to use to output of this dialog to search and replace strings
>in the located files. Therefore all I really need is the file locations containing
>the search text. Ideally I would like a cell array of all these locations to operate on.

may be just use dir()?

A=dir('*.m');

--Nasser

Subject: Function alternative to find files dialog

From: Richard Crozier

Date: 19 Apr, 2012 11:34:07

Message: 3 of 5

"Nasser M. Abbasi" <nma@12000.org> wrote in message <jmossl$dlv$1@speranza.aioe.org>...
> On 4/19/2012 6:17 AM, Richard Crozier wrote:
> > Does anyone know of a function alternative to the 'Find Files' dialog in Matlab?
> >
> > I would like to use to output of this dialog to search and replace strings
> >in the located files. Therefore all I really need is the file locations containing
> >the search text. Ideally I would like a cell array of all these locations to operate on.
>
> may be just use dir()?
>
> A=dir('*.m');
>
> --Nasser


The find files dialog searches for strings inside the files in a directory, and lists their occurrences, so I'm afraid dir won't work for me, thanks for replying though.

Subject: Function alternative to find files dialog

From: Nasser M. Abbasi

Date: 19 Apr, 2012 11:42:33

Message: 4 of 5

On 4/19/2012 6:34 AM, Richard Crozier wrote:

>
> The find files dialog searches for strings inside the files in a directory,
>and lists their occurrences, so I'm afraid dir won't work for me, thanks
>for replying though.

if you are on a linux box, you could always use system() from
Matlab. Inside system, you can use any bash command to do this
very easily (grep, find, etc...) and the result is retuned back
to Matlab in a variable. But the result is not a struct
or a cell array but a string. So, you might need to
post-process the result.

any way, just an idea.

--Nasser

Subject: Function alternative to find files dialog

From: Richard Crozier

Date: 19 Apr, 2012 11:56:21

Message: 5 of 5

"Nasser M. Abbasi" <nma@12000.org> wrote in message <jmotn8$fpi$1@speranza.aioe.org>...
> On 4/19/2012 6:34 AM, Richard Crozier wrote:
>
> >
> > The find files dialog searches for strings inside the files in a directory,
> >and lists their occurrences, so I'm afraid dir won't work for me, thanks
> >for replying though.
>
> if you are on a linux box, you could always use system() from
> Matlab. Inside system, you can use any bash command to do this
> very easily (grep, find, etc...) and the result is retuned back
> to Matlab in a variable. But the result is not a struct
> or a cell array but a string. So, you might need to
> post-process the result.
>
> any way, just an idea.
>
> --Nasser

Thanks, I'm aware of these functions too, but would really like a cross-platform all-matlab solution.

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us