From: Kirsten on
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!
From: Camille Couzi on
"Kirsten " <kirsten.swanson(a)swe.org> wrote in message <i3ufec$nto$1(a)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!
From: us on
"Kirsten " <kirsten.swanson(a)swe.org> wrote in message <i3ufec$nto$1(a)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
From: Camille Couzi on
"us " <us(a)neurol.unizh.ch> wrote in message <i3ugcr$qnp$1(a)fred.mathworks.com>...
> "Kirsten " <kirsten.swanson(a)swe.org> wrote in message <i3ufec$nto$1(a)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.
From: Jan Simon on
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