2

In batch, when I change to a different drive capitalized, it automatically corrects the capitalization of everything except fr the drive letter except fr when the new drive I am cding to is the same drive i'm currently in. Like so (this is just an example for demonstration purposes):

C:\Windows\System32>cd /d a:\eXaMpLe

a:\Example>cd /d A:\

A:\>cd /d a:\

A:\>echo.%CD%&cd /d a:\&echo.%CD%
A:\
A:\

A:\>exit /b 0

So, why is the capitalization behavior of the drive letter the way it is???

The Pepper
  • 29
  • 2
  • Which platform are you using? – aschipfl Apr 07 '16 at 09:35
  • @aschipfl - The [batch-file] tag, by its StackOverflow definition, implies Windows. and the prompt in the posted "code" lists the `C:\Windows\System32` folder. Isn't it kind of obvious what the platform is? – dbenham Apr 07 '16 at 10:49
  • @The Pepper - Why does it matter? It has no functional impact, unless you perform a case sensitive string comparison. But Windows paths are case insensitive, so all path string comparisons should be case insensitive anyway. – dbenham Apr 07 '16 at 10:55
  • 1
    @dbenham, actually I wanted to know which Windows version the OP is using... – aschipfl Apr 07 '16 at 11:01
  • 1
    @aschipfl - As far as I know, that behavior is true on all versions of Windows from at least XP onward. – dbenham Apr 07 '16 at 11:13

2 Answers2

1

I don't see how it matters, but that behavior is something I have noticed before.

I don't know the answer, but I can make an educated guess.

The case of the folder names is stored within the volume's directory, so the CD command simply uses the case within the directory, ignoring what was actually entered. But I don't think the volume letter is stored within the volume's directory, so the CD command simply preserves the drive letter case that was entered.

dbenham
  • 127,446
  • 28
  • 251
  • 390
0

I suppose the drive letter only exists without defined captialization.
You see only the last affecting of a cd, <driveLetter>:, pushd or popd command.

Theses commands are only affecting the directory when the new directory is different than it was before!

cd c:\
cd c:\windows  - Affects the directory and therefore the drive letter case
pushd C:\windows - doesn't affect the current directory
cd ..
popd - Affects the directory and therefore the drive letter case
jeb
  • 78,592
  • 17
  • 171
  • 225