Get correct case of file or folder by repeated calls of DIR
FileName = FileRealCase(FileName)
FileName: String, absolute path of an existing file or folder.
UNC paths are accepted.
FileName: String, absolute path with upper/lower case as set in the file system.
Matlab remembers the path as accessed in under Windows:
pathname = upper(fileparts(which('plot.m')));
% >> C:\PROGRAMME\MATLAB651\TOOLBOX\MATLAB\GRAPH2D
% >> C:\PROGRAMME\MATLAB651\TOOLBOX\MATLAB\GRAPH2D\plot.m
% >> C:\Programme\Matlab651\toolbox\matlab\graph2d\plot.m
I assume, this function is useful under Windows only, but it considers the Unix naming scheme also.
Matlab's WHICH can find the correct case of files inside the Matlab path also. But this fails for files in the current folder, if the folder was selected using a string with wrong case.
Jan (2021). FileRealCase (https://www.mathworks.com/matlabcentral/fileexchange/30395-filerealcase), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform CompatibilityWindows macOS Linux
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!