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:
Search for part of file name

Subject: Search for part of file name

From: Kirsten

Date: 11 Aug, 2010 15:26:04

Message: 1 of 5

I'm trying to figure out a way to search for only part of a filename. I have multiple files that have similar components.

For example:
abc123_5687482
abc124_8914573
abc125_1795362
abc126_7831568

I was wondering if there is a way to have MATLAB do a wildcard search to find if file abc123_5687482 exists by only using abc123 as the search. I've tried using exist() and fopen, but neither one of these seem to recognize wildcard inputs.

Thanks!

Subject: Search for part of file name

From: Camille Couzi

Date: 11 Aug, 2010 15:39:05

Message: 2 of 5

"Kirsten " <kirsten.swanson@swe.org> wrote in message <i3ufec$nto$1@fred.mathworks.com>...
> I'm trying to figure out a way to search for only part of a filename. I have multiple files that have similar components.
>
> For example:
> abc123_5687482
> abc124_8914573
> abc125_1795362
> abc126_7831568
>
> I was wondering if there is a way to have MATLAB do a wildcard search to find if file abc123_5687482 exists by only using abc123 as the search. I've tried using exist() and fopen, but neither one of these seem to recognize wildcard inputs.
>
> Thanks!


Hi Kirsten,
I am having the same sort of problem to solve, my file names finish in _V.dat, _D.dat ect...
I have been trying with regexp,and searching in the folder with ls.
I stay in contact with you if I find an effective way, and please tell me if you manage to do it too.

Bye!

Subject: Search for part of file name

From: us

Date: 11 Aug, 2010 15:42:19

Message: 3 of 5

"Kirsten " <kirsten.swanson@swe.org> wrote in message <i3ufec$nto$1@fred.mathworks.com>...
> I'm trying to figure out a way to search for only part of a filename. I have multiple files that have similar components.
>
> For example:
> abc123_5687482
> abc124_8914573
> abc125_1795362
> abc126_7831568
>
> I was wondering if there is a way to have MATLAB do a wildcard search to find if file abc123_5687482 exists by only using abc123 as the search. I've tried using exist() and fopen, but neither one of these seem to recognize wildcard inputs.
>
> Thanks!

a hint:

     help regexp;
% eg,

http://www.mathworks.com/matlabcentral/newsreader/view_thread/288917#770034

us

Subject: Search for part of file name

From: Camille Couzi

Date: 11 Aug, 2010 15:51:04

Message: 4 of 5

"us " <us@neurol.unizh.ch> wrote in message <i3ugcr$qnp$1@fred.mathworks.com>...
> "Kirsten " <kirsten.swanson@swe.org> wrote in message <i3ufec$nto$1@fred.mathworks.com>...
> > I'm trying to figure out a way to search for only part of a filename. I have multiple files that have similar components.
> >
> > For example:
> > abc123_5687482
> > abc124_8914573
> > abc125_1795362
> > abc126_7831568
> >
> > I was wondering if there is a way to have MATLAB do a wildcard search to find if file abc123_5687482 exists by only using abc123 as the search. I've tried using exist() and fopen, but neither one of these seem to recognize wildcard inputs.
> >
> > Thanks!
>
> a hint:
>
> help regexp;
> % eg,
>
> http://www.mathworks.com/matlabcentral/newsreader/view_thread/288917#770034
>
> us



Hi again,
Look at that too:
http://blogs.mathworks.com/pick/2008/09/09/advanced-matlab-file-name-processing-from-directory-listing/

Camille.

Subject: Search for part of file name

From: Jan Simon

Date: 11 Aug, 2010 17:05:23

Message: 5 of 5

Dear Kirsten,

> For example:
> abc123_5687482
> abc124_8914573
> abc125_1795362
> abc126_7831568
>
> I was wondering if there is a way to have MATLAB do a wildcard search to find if file abc123_5687482 exists by only using abc123 as the search. I've tried using exist() and fopen, but neither one of these seem to recognize wildcard inputs.

Do you mean this:
  d = dir('abc123*')
?

Good luck, Jan

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