批处理文件:
@echo off
echo.
echo Verifying existence of File
for %%d in (c d e f g h i j k l m n o p q r s t u v w x y z) do (
if exist %%d:\dir1\dir2\dir3\file1 (
set BDCPATH=%%d:\dir1\dir2\dir3\file1
) else if exist %%d:\dir1_2\dir2\dir3\file1 (
set BDCPATH=%%d:\dir1_2\dir2\dir3\file1
)
)
echo %BDCPATH%
echo %BDCPATH%
IF NOT EXIST %BCDPATH% echo %BCDPATH%
goto :eof
当我回显 '%BDCPATH% 变量时,它会取出驱动器号。你能解释一下为什么会发生这种情况并解决这个问题吗?
命令输出:
c:\Tools\KDNET_Helper>C:\Users\c_jamesp\Desktop\test1.bat
Verifying existence of BCD File
i:\dir1\dir2\dir3\file1
i:\dir1\dir2\dir3\file1
dir1\dir2\dir3\file1