List all and only files with no extension
Show older comments
How do I list all files in a folder without any extension?
3 Comments
Bob Thompson
on 20 Nov 2018
How does a file not have an extension? What type of file are you looking at?
Sam Smith
on 20 Nov 2018
Walter Roberson
on 20 Nov 2018
no extension is perfectly valid and common on Unix systems
Accepted Answer
More Answers (2)
Sam Smith
on 21 Nov 2018
1 Comment
Walter Roberson
on 22 Nov 2018
Too many input arguments -- dir only accepts a single input.
If you repair that to
dir(fullfile(foldername, '*.'))
then it will not do the desired task on Mac or Linux systems: on those systems it will only look for names that end in a literal '.', such as the '.' and '..' entries. On Mac and Linux, lack of a file extension is not treated as the pair (basic_name, empty_extension) the way it might be in DOS 3.1 : On Mac and Linux, '.' is just another character other than '.' as the complete component refers to the current directory, '..' as the complete component refers to the parent directory, and convention that files with '.' as a leading character will not be listed by default in directory listings.
Walter Roberson
on 20 Nov 2018
0 votes
dir() to get the directory content . Extract the file names to a cellstr. cellfun @fileparts with three outputs and uniform 0. cellfun @isempty the third output . The nonzero locations correspond to files with no extension whose full information you can get from the dir you ran
Categories
Find more on File Operations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!