- echo off&setlocal enabledelayedexpansion
- set var=\
- set /a count=0
- findstr /n "[" target.txt>>num.txt
- for /f "tokens=1-2 delims=[]" %%a in (num.txt) do (
- set /a count+=1
- if "%%b"=="!var!" set /a cal=0, skip=count,num=%%a 2>nul
- )
- for /f "skip=%skip% delims=" %%a in (num.txt) do set /a num2=%%a 2>nul
- for /f "skip=%num% delims=" %%i in (target.txt) do (
- echo %%i>>result.txt&set /a cal+=1,comp=cal+num+1
- if !comp! equ !num2! echo 您要的内容已成功提取!&goto end
- )
- :end
- pause>nul
复制代码
|