@echo off
rem 查询 searchd 服务是否存在
sc query |find /i "searchd" >nul 2>nul
if not errorlevel 1 (goto exist) else goto notexist
rem 存在 searchd 服务
:exist
@echo.
pause
goto :eof
rem 不存在 searchd 服务
:notexist
setlocal enabledelayedexpansion
set txt=%cd%
set txt=!txt:\=/!
rem 查找 source.txt 文件中的 @DIR@ 替换成 %cd%(当前路径),并保存到文件 target.txt
call :replace %cd%\source.txt @DIR@ %txt% >%cd%\target.txt
@echo.
pause
goto :eof
rem 查找替换代码
:replace
for /f "tokens=1,2* delims=:" %%i in ('findstr /n ".*" %1') do (
set txt=%%j
if "!txt!" == "" (
echo.
) else (
echo !txt:%2=%3!
)
)
goto :eof
JavaScript 查找替换
点赞
收藏