展开全部
提取a.txt前两行到b.txt
@echo off
setlocal enabledelayedexpansion
for /f "tokens=*" %%i in (a.txt) do (
echo %%i>>b.txt
set /a n+=1
if !n!==2 exit)
@echo off
setlocal enabledelayedexpansion
for /f "tokens=*" %%i in (a.txt) do (
echo %%i>>b.txt
set /a n+=1
if !n!==2 exit)
追问
如果有很多的文件,想全部把前两行存到 b.txt里,怎么写
追答
@echo off
setlocal enabledelayedexpansion
(for /f "tokens=*" %%a in ('dir/b *.txt') do (
for /f "tokens=*" %%i in ('type "%%a"') do (
set /a n+=1
if !n! leq 2 echo %%i)
set n=))>b.txt
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询