批量为什么驱动器信件变得无资本化

时间:2016-04-06 21:17:17

标签: batch-file directory cd capitalization drive-letter

批处理时,当我更改为不同的驱动器大写时,它会自动更正驱动器号以外的所有内容的大小写,除了fr之外我正在使用的新驱动器是我当前所在的驱动器。所以(这只是用于演示目的的一个例子):

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

那么,为什么驱动器盘符的大写行为是这样的呢?

2 个答案:

答案 0 :(得分:1)

我不知道它的重要性,但这种行为是我之前注意到的。

我不知道答案,但我可以做出有根据的猜测。

文件夹名称的大小写存储在卷的目录中,因此CD命令只使用目录中的大小写,忽略实际输入的内容。但我不认为卷号存储在卷的目录中,因此CD命令只保留输入的驱动器号字大小写。

答案 1 :(得分:0)

我认为驱动器号只存在没有定义的captialization 您只会看到cd<driveLetter>:pushdpopd命令的最后影响。

Theses命令仅在新目录与之前的目录不同时影响目录!

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