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