Batch Why Do Drive-Letters Become Uncapitalized

541 Views Asked by At

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???

2

There are 2 best solutions below

0
dbenham On

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.

0
jeb On

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