이 시도 - 너무 특수 기호를 처리 할 수 있어야합니다 (이 endsWith 서브 루틴을 사용) : (이 외부 명령에 의존로 아마 속도가 느려집니다)
이
@echo off
:::example calls of :endsWith subroutine
call :endsWith abcdefgh fgh
echo %errorlevel%
call :endsWith abcdefgh abc
echo %errorlevel%
exit /b 0
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:endsWith [%1 - string to be checked;%2 - string for checking ]
@echo off
rem :: sets errorlevel to 1 if %1 ends with %2 else sets errorlevel to 0
setlocal EnableDelayedExpansion
set "string=%~1"
set "checker=%~2"
set LF=^
rem ** Two empty lines are required
rem echo off
for %%L in ("!LF!") DO (
for /f "delims=" %%R in ("!checker!") do (
set "var=!string:%%~R=%%L#!"
)
)
for /f "delims=" %%P in (""!var!"") DO (
set "temp=%%~P"
)
if "%temp%" EQU "#" (
endlocal & exit /b 1
) else (
endlocal & exit /b 0
)
goto :eof
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
또한 FINDSTR
가 사용할 수 있습니다
echo abcdefgh| findstr /e "fgh" >nul 2>nul && (
echo ends with
)||(
echo does not ends with
)
'SET' 명령에 대한 도움말 파일에 설명 된대로 부분 문자열을 사용할 수 있습니다. 'IF/I "="== "% cho : ~ -7 %"echo match' – Squashman