批量将字符转为小写

Convert char to lowercase in batch

我在尝试将 windows 路径转换为类似 cygwin 风格的 linux 路径时遇到问题。例如,C:\path\to\file 将是 /cygdrive/c/path/to/file。除了将从路径中拉出的大写驱动器号转换为小写之外,我一切正常。这些问题大家给出的link是:

http://www.robvanderwoude.com/battech_convertcase.php

和"SET, Take Two"下的for循环似乎是最合适的。这是我目前所拥有的:

@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION

SET CWRSYNCHOME=%~dp0

echo the windows path is %CWRSYNCHOME%
for /f "tokens=1,2 delims=:" %%a in ("%CWRSYNCHOME%") do (
set "manip1=%%a"
set "manip2=%%b"
echo starts as /cygdrive/!manip1!!manip2:\=/!
FOR %%i IN ("A=a" "B=b" "C=c" "D=d" "E=e" "F=f" "G=g" "H=h" "I=i" "J=j" "K=k" "L=l" "M=m" "N=n" "O=o" "P=p" "Q=q" "R=r" "S=s" "T=t" "U=u" "V=v" "W=w" "X=x" "Y=y" "Z=z") DO SET "manip1=%manip1:!%%i!%"&echo doing: "manip1=%manip1:!%%i!%"&echo now its !manip1!
set "CYGLIKEHOME=/cygdrive/!manip1!!manip2:\=/!"
)
echo the converted path is %CYGLIKEHOME%
PAUSE
GOTO :EOF

我得到的输出是:

the windows path is E:\cwRsync_5.5.0_x86_Free\SANDBOX\
starts as /cygdrive/E/cwRsync_5.5.0_x86_Free/SANDBOX/
the converted path is /cygdrive/ "manip1="
now its  "manip1="
now its  "manip1="
now its  "manip1="
now its  "manip1="
now its  "manip1="
now its  "manip1="
now its  "manip1="
now its  "manip1="
now its  "manip1="
now its  "manip1="
now its  "manip1="
now its  "manip1="
now its  /cwRsync_5.5.0_x86_Free/SANDBOX/
Press any key to continue . . .

是否有更好的方法将单个字符转换为小写?如果没有,你们能看到我在设置 CYGLIKEHOME 时做错了什么吗?

谢谢

!%%i! 完全没有意义。

%manip1:!%%i!% 应该是 !manip1:%%~i!