MATLAB: Issues of Sensitive in ‘dir’ function

filename case sensitive dir

There is a file named abc.m, but I'm not sure the name is abc.m or Abc.m.
How to determine the true name of file?
I have a test with the true name of file is abc.m
a=dir('abc.m') %a.name=abc.m
and
b=dir('Abc.m') %b.name=Abc.m,
So, I don't know how to deal this question.

Best Answer

d = dir('*.m');
match = strcmpi({d.name}, 'abc.m'); % [EDITED] strcmp*i*
Name = d(match).name;
Another implementation: FEX: FileRealCase. This adjusts the upper/lower case of the path also.