How to save sequence of file names into an array?

121 views (last 30 days)
I have a folder full of files in it and I want to save the name of files in an array. Each cell corresponds to a string of the file name. How can I do this?

Answers (2)

Walter Roberson
Walter Roberson on 20 Aug 2013
dinfo = dir('YourDirectory');
names_cell = {};
You might also want to
strcat('YourDirectory', '/', names_cell)
if you want to construct the more qualified file names.

the cyclist
the cyclist on 20 Aug 2013
Edited: the cyclist on 20 Aug 2013
Use the dir command.
>> s = dir;
will create a structure with a list of all the files and directories. If you need help converting that info from a structure to a cell array, I recommend you post a second question about that.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by