Borrar filtros
Borrar filtros

Checking the existence of any file with a specific extension in a directory

52 visualizaciones (últimos 30 días)
I require to check whether any file exists with a specific extension in a given folder. Let us say, I look for whether any .pdf file is present in my working directory. MATLAB does not accept wildcard commands like
exist('*.m')
Any solution?

Respuesta aceptada

Stephen23
Stephen23 el 11 de Mzo. de 2015
Editada: Stephen23 el 12 de Mzo. de 2015
Use dir instead. If you only want to know about the existence, then you could simply check if the returned structure is not empty:
~isempty(dir('*.m'))

Más respuestas (0)

Categorías

Más información sobre File Operations 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