我正在尝试制作一个bat文件,该文件将我制作的自定义扩展文件中的标签本地化并获得输出,问题在于,由于在没有启动本地环境的情况下显然无法在FOR循环中增加变量,我不能那样做。
@echo off
SET _TSL=%3
SET _forcount=1
SET _COLONLINE=0
SET /a _LINESKIP=%_TSL%-1
if "%5"=="1" (
echo [Mesa Markdown Debug] File Directory : %1
echo [Mesa Markdown Debug] Target Colon : %2
echo [Mesa Markdown Debug] Line : %_LINESKIP%
echo [Mesa Markdown Debug] Item : %4
echo [Mesa Markdown Debug] DebugMode : %5
echo.
)
setlocal ENABLEDELAYEDEXPANSION
for /F "eol=$ usebackq" %%i in (%1) do (
SET /A _forcount=_forcount+1
if "%%i"=="%2" SET _COLONLINE=!_forcount!
)
if "%5"=="1" (echo [Mesa Markdown Debug] Target Colon is: %_COLONLINE%)
SET /a _LINESKIP=%_LINESKIP%+%_COLONLINE%
if "%5"=="1" (echo [Mesa Markdown Debug] Target line acquired: %_LINESKIP%)
for /F "eol=$ skip=%_LINESKIP% delims=" %%i in (%1) do if not defined _mmkstring (SET _mmkstring=%%i)
if "%5"=="1" (echo [Mesa Markd
own Debug] Conent of line %_LINESKIP%: %_mmkstring%)
if "%_mmkstring%"=="" (echo [Mesa Markdown] Error @ line %_LINESKIP% of %1 - The line appears empty.)
if "%4"=="1" (for /F "tokens=1-9* delims={}," %%a in ("%_mmkstring%") do SET _mmk=%%a)
if "%4"=="2" (for /F "tokens=1-9* delims={}," %%a in ("%_mmkstring%") do SET _mmk=%%c)
if "%4"=="3" (for /F "tokens=1-9* delims={}," %%a in ("%_mmkstring%") do SET _mmk=%%e)
endlocal
在另一个单独的批处理文件中,“ echo%_mmk%不返回任何内容。