使用命令 `dir` 列出没有任何扩展名的文件

List files that don't have any extension using command `dir`

在包含具有不同扩展名的文件的目录中,例如.ext1.ext2</code>(无扩展名),如何使用<code>dir命令只列出没有任何扩展名的文件扩展?

命令 dir(fullfile('path/to/dir','*.ext1')) 将列出所有 .ext1 个文件,但我不知道有任何选项可以读取无扩展名文件。

请尝试以下是否满足您的所有需求:

allfiles = dir
filelist = {allfiles(3:end).name}

mask = cellfun(@isempty, regexp( filelist ,'[^\]*(?=[.][a-zA-Z]+$)','match'))
output = filelist(mask)

正则表达式查找所有 具有扩展名 和 returns 如果没有则为空数组的文件名。因此 cellfun(@isempty, ... ) 会给你想要的面具。