为什么我下面的这段代码运行后总是提示系统找不到路径呢?
@echo off
setlocal enabledelayedexpansion
color 0A
::=====检查初始化文件是否存在=====
:setinit_loop
if not exist "!userprofile!\setinit.bat" (
set sourcepath=\\a\ma
echo 请输入存放文件的路径!
set /p targerpath= [参考格式c:\ct\] :
if "!targerpath!" == "" (
echo 你输入的为空路径!
goto setinit_loop
) else (
echo "!targerpath!"|findstr /i "[A-Z]:\\.*" >nul 2>nul||(echo 错误:路径格式1不正确!&goto :setinit_loop)
echo "!targerpath!"|findstr /i ".*/.*" >nul 2>nul&&(echo 错误:路径格式2不正确! &goto :setinit_loop)
if not exist !targerpath:~0,2!\nul (echo 错误:无此盘!&goto :setinit_loop)
if not exist "!targerpath!" (md "!targerpath!")
echo set targerpath=!targerpath! > "!userprofile!\setinit.bat"
echo set sourcepath=!sourcepath! > "!userprofile!\setinit.bat"
)
) else (
start /I /B "!userprofile!\setinit.bat"
cls
)
@echo off
setlocal enabledelayedexpansion
color 0A
::=====检查初始化文件是否存在=====
:setinit_loop
if not exist "!userprofile!\setinit.bat" (
set sourcepath=\\a\ma
echo 请输入存放文件的路径!
set /p targerpath= [参考格式c:\ct\] :
if "!targerpath!" == "" (
echo 你输入的为空路径!
goto setinit_loop
) else (
echo "!targerpath!"|findstr /i "[A-Z]:\\.*" >nul 2>nul||(echo 错误:路径格式1不正确!&goto :setinit_loop)
echo "!targerpath!"|findstr /i ".*/.*" >nul 2>nul&&(echo 错误:路径格式2不正确! &goto :setinit_loop)
if not exist !targerpath:~0,2!\nul (echo 错误:无此盘!&goto :setinit_loop)
if not exist "!targerpath!" (md "!targerpath!")
echo set targerpath=!targerpath! > "!userprofile!\setinit.bat"
echo set sourcepath=!sourcepath! > "!userprofile!\setinit.bat"
)
) else (
start /I /B "!userprofile!\setinit.bat"
cls
)
实用就是好东西!
