From: Jessica on
I am trying to get a list of all the .xls files in a folder by using the dir command (I want to get it so that each file can then be called up separately):

FileNames=dir('/Volumes/Drive12/'')
FileNames(1).name
FileNames(2).name
FileNames(3).name
..
..
..


However, when I try to just get the .xls files, it doesn't work:

FileNames=dir('/Volumes/Drive12/','*.xls').

Any suggestions for what is wrong with my code?

Thanks!
From: Walter Roberson on
Jessica wrote:

> However, when I try to just get the .xls files, it doesn't work:
>
> FileNames=dir('/Volumes/Drive12/','*.xls').
>
> Any suggestions for what is wrong with my code?

You failed to mention the error you get,

??? Error using ==> dir
Too many input arguments.

That was a clue that you should examine the documentation of dir() and
notice that it can only take a single argument. Try

dir('/Volumes/Drive12/*.xls')
From: ImageAnalyst on
With my version of MATLAB, dir() does not take two arguments. Try

FileNames = dir('/Volumes/Drive12/*.xls');

or

FileNames = dir(fullfile('/Volumes/Drive12/', '*.xls'));
which is similar to the example the help shows,
and which is the same as
FilePattern = fullfile('/Volumes/Drive12/', '*.xls');
FileNames = dir(FilePattern);

From: us on
"Jessica" <jyorzinski(a)ucdavis.edu> wrote in message <hvhf0s$50$1(a)fred.mathworks.com>...
> I am trying to get a list of all the .xls files in a folder by using the dir command (I want to get it so that each file can then be called up separately):
>
> FileNames=dir('/Volumes/Drive12/'')
> FileNames(1).name
> FileNames(2).name
> FileNames(3).name
> .
> .
> .
>
>
> However, when I try to just get the .xls files, it doesn't work:
>
> FileNames=dir('/Volumes/Drive12/','*.xls').
>
> Any suggestions for what is wrong with my code?
>
> Thanks!

well, yes...
what about using the correct syntax, eg,

one of the solutions

fn=dir('/Volumes/Drive12/*.xls')

us