Effacer les filtres
Effacer les filtres

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

52 vues (au cours des 30 derniers jours)
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?

Réponse acceptée

Stephen23
Stephen23 le 11 Mar 2015
Modifié(e) : Stephen23 le 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'))

Plus de réponses (0)

Catégories

En savoir plus sur File Operations dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by