List of files that do not have an extension with the `dir` command

In a directory containing files with different extensions, for example. .ext1, .ext2and (without extension), how can I use the command dirto list only files that do not have an extension?

The command dir(fullfile('path/to/dir','*.ext1'))will list all the files .ext1, but I do not know any option to read files with the extension without restrictions.

+4
source share
1 answer

Try it if the following meets all your needs:

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

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

, , , . cellfun(@isempty, ... ) .

+5

Source: https://habr.com/ru/post/1609660/


All Articles