MATLAB: Problems with the name when listing files if no extension is specified

dirfiles extensionname

I'm trying to list files in a folder using dir. Everything is alright when the files have an extension and I can specify it (i.e. A=dir('*.xlsx')).
I have however a problem when I do not specify the extension (dir('*.*') or dir(nameofthefolder) or simply dir): then the field 'name' of each file listed in A is a dot (i.e. A(1).name = '.').
I am listing files that apparently do not have an extension and it is required to read their name, so I need to be able to list them correctly without giving the extension.

Best Answer

FileList = dir('*.*');
FileList([FileList.isdir]) = []; % Remove all directories including . and ..
Now your file list contains files only and the current folder . and the parent folder .. are excluded also.