Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

case sensitive dir in cmd.exe

I just experienced a search dir *T.java in a cmd.exe giving back SortedArrayList.java as well as ReaderT.java (my Test class filename structure). I can't infer a case sensitivity switch from the help output of dir /?. Is there still a way though?

Addendum: I assume from the answers "Windows File System" refers to NTFS or FAT[32].

For my purposes I got inspired from the answers to use dir /b /s *T.class | grep T\. Which created a new question

like image 682
panny Avatar asked Oct 27 '25 09:10

panny


2 Answers

Just a quick google-fu:

1.1 Introduction to Windows' File System

In Windows, files are organized in directories (aka folders). The directories are organized in a hierarchical tree structure, starting from the root directory. A directory may contain sub-directories and files. The root directory is denoted as "\" (back-slash).Windows' file system is further organized in drive, identified by a drive letter followed by a colon (e.g., C:, D:, E:). Each drive has its own root directory, such as C:\, D:. Windows' file system is NOT case-sensitive, a rose is a Rose, and is a ROSE.

So no, there is no "case-senstive" option when using DIR. On the other hand, you can try to check case sensitivity on the side of the program which will be executing the file search.. In this case Java, as I presume. Just get all the files which match and then filter out the case-insensitive matches in Java.

like image 73
Dropout Avatar answered Oct 29 '25 23:10

Dropout


Not to my knowledge. Windows file system is not case-sensitive, and until more recently you couldn't rely on your capitalisations to be preserved (okay so I'm thinking back a few versions of Windows now). So, as a result, Microsoft's dir command completely ignores the fact that you might want case-sensitivity.

Instead, you should try piping the output through grep for Windows, which is part of the GnuWin32 project: http://gnuwin32.sourceforge.net/packages/grep.htm

A complete list of packages is at: http://gnuwin32.sourceforge.net/packages.html

Pretty useful stuff to have if you have a Linux background and are forced into doing anything remotely useful in Windows command shell.

So, long story short, you'd want to do something like:

dir /b | grep T\.java
like image 24
paddy Avatar answered Oct 30 '25 01:10

paddy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!