When Matlab read file, file name is case insenstive?

7 visualizzazioni (ultimi 30 giorni)
If I save a file a abc.csv. It looks like when I read this file, I can use both abc.CSV or AbC.csv? If yes, can you give a reference link?

Risposta accettata

Walter Roberson
Walter Roberson il 1 Mar 2016
Not exactly. MATLAB itself cares about case. However, by default MS Windows NTFS filesystem is not case sensitive (and the FAT* filesystems never even had the option to be anything else); and by default OS-X's HFS filesystem is not case sensitive. So if you are using one of those filesystems, although MATLAB passes the exact name you specify to the operating system, when the operating system passes the name through the filesystem code, the filesystem might match case in-sensitive.
This leads to the old trick on MS Windows: if you want to change the "official" case of a filename, you cannot just rename it from one name to another version of the name in a different case, because the filesystem says "Those are the same". Instead you rename it to some different name and then rename that other name to the final desired name. For example,
rename('abc.CSV', 'temporary.csv'); rename('temporary.csv', 'abc.csv');
Note: it is possible to configure NTFS to be case sensitive, and it is possible to configure OS-X HFS filesystems to be case sensitive.

Più risposte (0)

Categorie

Scopri di più su Files and Folders in Help Center e File Exchange

Tag

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by