000*_*111 4 matlab file-extension dir
在包含具有不同扩展名的文件的目录中,例如.ext1,.ext2和 (no extension), how can I use the 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)
Run Code Online (Sandbox Code Playgroud)
正则表达式查找具有扩展名的所有文件名,否则返回空数组.因此cellfun(@isempty, ... )会给你想要的面具.