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

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

rssFeed for this Thread

Public Submission Policy

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Disclaimer prior to use.

Contact us at files@mathworks.com