Borrar filtros
Borrar filtros

How do I count the number of .CSV files in a folder?

304 visualizaciones (últimos 30 días)
Brian
Brian el 18 de Nov. de 2013
Comentada: Guillaume el 3 de Jun. de 2017
Hi,
I would like to know how to count the number of .CSV files in my folder? I have to do this for multiple folders so I would like to choose them.
So far I have something like this...
source_dir = uigetdir([]);
d = dir([source_dir, '\*.csv']);
n=length(d(not([d.isdir])));
but I get an error at the second line. Help!

Respuestas (1)

Image Analyst
Image Analyst el 18 de Nov. de 2013
  6 comentarios
Miranda Zhang
Miranda Zhang el 3 de Jun. de 2017
Do you use Mac OS? I had the same problem but then realised it's because I'm supposed to use '/' instead of '\' because it's not Windows.
Guillaume
Guillaume el 3 de Jun. de 2017
because I'm supposed to use '/' instead of '\' because it's not Windows.
... and that is why you use fullfile instead of building your own paths by string concatenation. fullfile will do the right thing regardless of which platform you're on.

Iniciar sesión para comentar.

Categorías

Más información sobre Environment and Settings en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by