我无法尝试将Windows路径转换为cygwin风格的linux路径。例如,C:\ path \ to \ file将是/ cygdrive / c / path / to / file。除了将从路径中拉出的大写驱动器号转换为小写之外,我已经完成了所有工作。每个人都为这些问题提供的链接是:
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时看到我做错了吗?
谢谢
答案 0 :(得分:1)
!%%i!
毫无意义。
%manip1:!%%i!%
应为!manip1:%%~i!