I have a folder with a bunch of png images:
I read the contents of the folder using the dir command:
which returns a structure, the name field of which contains:
I would like to remove the invalid entries generated by the Windows file structure. I am sure there is an easy way to do this!
Seems like it should be possible to do using cellfun, but
str = '.png';
fileList = fileList(cellfun(@contains str, fileList.name));
Creating a loop and using contains seems inefficient, but I don't have too many files:
for ii = 1:length(fileList)
idx(ii) = contains('.png',fileList(ii).name);
bizarrely returns idx = 1 0 0 0...
Interestingly, the contains command appears to not work as I expect:
which explains why my loop approach doesn't work...
This is a problem I face regularly, so any help would be appreciated!