MATLAB: Output of evalc

dirdirectoryevalcls

Hi, I am trying to load the filenames of 10000+ files (on a network path).
dir & ls seem the obvious commands, but they are both slow (33s for 18k files).
evalc on the other hand takes less than a second. (evalc('dir(…)')) however, the output is in a 1-d char array consisting of all filenames. There are spaces in the filenames as well, so that makes seperating a bit troublesome.
is it possible to get a different output format, or does anyone know a different "solution"?
Thanks! Jaap
PS. It's on a 32bit winXP

Best Answer

It seems that
evalc(['dir(', FilePath. ')'])
should go faster than
D = dir(FilePath);
since the evalc method only gets the file names while the direct call gets additional information. On a local filesystem, it probably doesn't matter much, but over a network it could make a big difference.
What about using the system call. On Windows that would be
[~, filenameArray] = system('dir /b');
and on Linux it would be
[~, filenameArray] = system('ls -1');
(note it is a one and not an el). . If you have oddly named or hidden files you may need more parameters.