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

41 visualizzazioni (ultimi 30 giorni)
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?

Risposta accettata

Stephen23
Stephen23 il 11 Mar 2015
Modificato: Stephen23 il 12 Mar 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'))

Più risposte (0)

Categorie

Scopri di più su File Operations in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by