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:
List file names

Subject: List file names

From: Jessica

Date: 8 Sep, 2008 14:36:02

Message: 1 of 2

Hi,

Does anyone know how I can generate a list of all the files in a folder that have a certain name? For example, I have a folder with the following files:

One Data.txt
Two Data.txt
Three Data2.txt
Four Data.txt

I would like Matlab to output a list of only the Data.txt files:

One Data.txt
Two Data.txt
Four Data.txt

I have tried:

 filelist=dir('C:\Users\')

but it doesn't seem to list all the file names.

Thanks!

Subject: List file names

From: Walter Roberson

Date: 8 Sep, 2008 17:36:39

Message: 2 of 2

Jessica wrote:

> Does anyone know how I can generate a list of all the files in a folder that
> have a certain name? For example, I have a folder with the following files:
 
> One Data.txt
> Two Data.txt
> Three Data2.txt
> Four Data.txt

> I would like Matlab to output a list of only the Data.txt files:

You -should- be able to use wildcards, as in

filelist = dir('C:\Users\*Data.txt');

> I have tried:
> filelist=dir('C:\Users\')
> but it doesn't seem to list all the file names.

I wonder... if you cd to that directory first and then filelist=dir() do you
get a different list of files? And is it possible that some of the files
might be shortcuts ?

--
Q = quotation(rand);
if isempty(Q); error('Quotation server filesystem problems')
else sprintf('%s',Q), end

Tags for this Thread

No tags are associated with 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