第2个回答 2015-03-06
@echo off
setlocal enabledelayedexpansion
for /f "delims=` tokens=* eol=a" %%a in (test.txt) do (
if "%%a"=="bbb" goto :n
set %%a
set pth=!str1!
)
:n
find /n "bbb" test.txt>temp.tmp
for /f "delims=] tokens=1-2 eol=`" %%a in (temp.tmp) do (
set l=%%a
set l=!l:[=!
set l=!l: =!
goto :o
)
:o
for /f "delims=` tokens=* eol=` skip=!l!" %%a in (test.txt) do (
set %%a
)
echo !str1!>!pth!\aaa.txt