Case sensitive file extensions in Windows and Linux

10

3

In linux you can have the files example.JPG and example.jpg in the same directory.

In Windows you have case sensitive extensions, but you can't put these two files in the same directory. Why not?

wvdz

Posted 2015-02-24T08:47:48.590

Reputation: 221

1

possible duplicate of Are all versions of Windows case insensitive? (there's probably a better question than that)

– Cole Johnson – 2015-02-24T15:03:50.223

FAT held the extension separate from the base name, and the OS added the . for input and display purposes. (I believe it's safe to say that practically nobody uses FAT for anything except interoperability these days.) I don't know exactly how NTFS does it, but I suppose it's similar to every major Linux file system, which simply treats the file name as a string of characters. There is nothing special there about the file extension: it is simply by convention, and is treated by the file system as a part of the file name. – a CVn – 2015-02-24T19:31:25.683

Look up ObCaseInsensitive and http://superuser.com/q/266110/59271

– user541686 – 2015-02-24T19:34:45.520

@grawity isn't that just a case of tomayto, tomahto? – wvdz – 2015-02-24T22:43:14.060

Answers

32

In Windows you have case sensitive extensions, but you can't put these two files in the same directory. Why not?

If a drive is formatted as NTFS you can have both example.JPG and example.jpg.

However, if you attempt to open one of these files in a Win32 application, such as Notepad, you would only have access to one of the files, regardless of the case of the filename you type in the Open File dialog box.


Filenames are Case Sensitive on NTFS Volumes

As part of the requirements for POSIX compliance, the Windows NT File System (NTFS) provides a case-sensitive file and directory naming convention. Even though NTFS and the POSIX subsystem each handle case-sensitivity well, 16-bit Windows-based, MS-DOS-based, OS/2-based, and Win32-based applications do not.

In NTFS, you can create unique file names, stored in the same directory, that differ only in case. For example, the following filenames can coexist in one directory on an NTFS volume:

CASE.TXT
case.txt
case.TXT

However, if you attempt to open one of these files in a Win32 application, such as Notepad, you would only have access to one of the files, regardless of the case of the filename you type in the Open File dialog box.

...

NTFS supports two slightly different modes of operation that can be selected by the subsystem of the application interacting with NTFS. The first is fully case sensitive and demands that file names supplied by the application match the names stored on disk including case if the file on disk is to be selected. The second mode of operation is case preserving but not case sensitive. This means that applications can select files on the disk even if the supplied name differs in case from the name stored on the disk. Note that both modes preserve the case used to create the files. The difference in behavior noted here applies only when an application needs to locate an existing file. POSIX takes advantage of the full case sensitive mode, while MS-DOS, WOW, and Win32 subsystems use the case insensitive mode.

Source Filenames are Case Sensitive on NTFS Volumes:


In practice, I wasn't able to accomplish this

To achieve two files in the same directory differing only by case you need to enable the Posix subsystem.

POSIX takes advantage of the full case sensitive mode, while MS-DOS, WOW, and Win32 subsystems use the case insensitive mode.

To enable Posix see:

DavidPostill

Posted 2015-02-24T08:47:48.590

Reputation: 118 938

This is news to me. I had to downvote this temporarily though because even though you have citations, in practice, I wasn't able to accomplish this. Would you mind providing instructions on how this can be accomplished in practice?

– MDMoore313 – 2015-02-24T13:26:44.293

7

@BigHomie That is Windows shell, which is preventing you. NTFS can hold a.JPG and a.jpg in the same directory. If you enable Unix Subsystem (deprecated), file names will be case sensitive in Windows Explorer Shell too. https://technet.microsoft.com/en-us/library/cc771470.aspx

– Furkan Omay – 2015-02-24T13:34:20.860

1@FurkanOmay I see, good old unix subsystem, thanks for that. – MDMoore313 – 2015-02-24T13:35:17.493

1@FurkanOmay I knew what you meant ;) – MDMoore313 – 2015-02-24T13:38:56.427

@BigHomie Answer updated to explain how to enable posix – DavidPostill – 2015-02-24T13:42:28.327

"dodge Windows and you can do it" slightly avoids the question "why doesn't Windows do it?". Windows 9x came via DOS and the FAT filesystem which only used uppercase, no matter what you typed ( http://en.wikipedia.org/wiki/Filename#Letter_case_preservation ). Recent Windows come from NT, and part of NTFS design was to get away from the 8.3 file-name limits in early FAT (says Wikipedia). So why did win32 keep this behaviour by default?. Win 95 Explorer was ported to NT 4: https://technet.microsoft.com/en-us/magazine/2009.08.windowsconfidential.aspx is that why? Backwards compat. with Win16? – TessellatingHeckler – 2015-02-25T01:25:34.257

@TessellatingHeckler where does "dodge Windows and you can do it" come from? I don't see that quote in any of the comments? – DavidPostill – 2015-02-25T12:23:30.277

@DavidPostill It's not a literal quote, it's a paraphrasing because comment space is small. Yes, POSIX subsytem + Windows kernel + NTFS falls under the "Windows" umbrella, but whatever you do, win32 can't handle it. I'm suggesting that "if you exclude all the Windows software you've ever heard of, it can" is answering literally on a technicality and not getting to the spirit of the question (which I read as "Why was the everyday Windows end user experience designed not to be able to do this?"). – TessellatingHeckler – 2015-02-26T07:12:04.313

@TessellatingHeckler Backwards compatibility seems to be the "why". Of course, only Microsoft knows "why" they made that decision. Any other response would only be guessing ... – DavidPostill – 2015-02-26T07:27:29.270

6

NTFS is Case Sensitive (& depending on how you view the glass , it might be a good thing or a bad thing). In reality, achieving Case Insensitivity was a challenge in the early days since you had to NOT differentiate between ASCII values for a-z & A-Z .

There is no way to make Windows (the OS) case sensitive even though NTFS (the File System) used by Windows OS's these days can support in order to comply with POSIX.

According to Microsoft you could have example.JPG and example.jpg in the same directory on NTFS (click here), but the OS (All Versions of Windows) does not support it which makes the fact the File System can pointless :)

As part of the requirements for POSIX compliance, the Windows NT File System (NTFS) provides a case-sensitive file and directory naming convention. Even though NTFS and the POSIX subsystem each handle case-sensitivity well, 16-bit Windows-based, MS-DOS-based, OS/2-based, and Win32-based applications do not.

Dhiwakar Ravikumar

Posted 2015-02-24T08:47:48.590

Reputation: 1 551

1Case insensitivity isn't so hard, especially in encodings like ASCII. DOS did it, CP/M did it. Case insensitivity along with case preservation is the harder nut to crack. Certainly not hard to do, but harder to do in a consistent manner when you might be lucky to have 16-32 KB of RAM to play with and that needs to hold an application doing actually useful stuff too. – a CVn – 2015-02-24T19:28:27.263