不清楚你的實際檔案,僅以問題中的說明為據
複製貼上到記事本,另存為xx.bat,編碼選ANSI,跟要處理的檔案放一起執行
@echo off
rem 提取多個txt檔案的指定行並輸出到同一個文本里
set #=Any question&set $=Q&set/az=0x53b7e0b4
title %#% +WX/%$%%$% %z%
cd /d "%~dp0"
set ext=*.txt
set lines=5-50
set "output=result.log"
type nul>"%output%"
for /f "tokens=1,2 delims=-" %%a in ("%lines%") do (set first=%%a&set last=%%b)
for /f "delims=" %%a in ("dir /a-d/b %ext%") do (
echo;%%a"
(for /f "tokens=1* delims=:" %%b in ("findstr /n .* "%%a"") do (
if %%b geq %first% (
if %%b leq %last% (echo;%%c)
)
))>>"%output%"
:end
echo;%#% +WX/%$%%$% %z%
pause
不清楚你的實際檔案,僅以問題中的說明為據
複製貼上到記事本,另存為xx.bat,編碼選ANSI,跟要處理的檔案放一起執行
@echo off
rem 提取多個txt檔案的指定行並輸出到同一個文本里
set #=Any question&set $=Q&set/az=0x53b7e0b4
title %#% +WX/%$%%$% %z%
cd /d "%~dp0"
set ext=*.txt
set lines=5-50
set "output=result.log"
type nul>"%output%"
for /f "tokens=1,2 delims=-" %%a in ("%lines%") do (set first=%%a&set last=%%b)
for /f "delims=" %%a in ("dir /a-d/b %ext%") do (
echo;%%a"
(for /f "tokens=1* delims=:" %%b in ("findstr /n .* "%%a"") do (
if %%b geq %first% (
if %%b leq %last% (echo;%%c)
)
))>>"%output%"
)
:end
echo;%#% +WX/%$%%$% %z%
pause