使用 Windows cmd 或 Cygwin,有没有办法获取大小写正确的实际文件 path/name?

With Windows cmd or Cygwin, Is there a way to get the actually file path/name with proper case?

有没有办法使用 Windows cmd 或 Cygwin 来获取大小写正确的实际文件 path/name?例如,

输入:

c:\windows\system32\display.dll

输出

C:\Windows\System32\Display.dll

您可以使用 FOR /F 回显或获取大小写更正后的文件名

for /F "delims=" %%X in ("c:\windows\system32\display.dll") do echo %%~fX

盘符的大小写好像还没有确定。
对于同一个驱动器,它可以是大写或小写。
我用

测试了它
c:\> pushd C:\
C:\> popd
c:\> pushd c:\
c:\>

因此您可以简单地强制驱动器号始终为小写。