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

조회 수: 45 (최근 30일)
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?

채택된 답변

Stephen23
Stephen23 2015년 3월 11일
편집: Stephen23 2015년 3월 12일
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'))

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 File Operations에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by