比如要删除各个文档中的第5~10行,未测试:- @echo off
- set linenum1=5
- set linenum2=10
- setlocal enabledelayedexpansion
- for /f "delims=" %%i in ('dir /b /a-d *.txt') do (
- set n=0
- (for /f "delims=" %%a in ('type "%%i"') do (
- set /a n+=1
- if !n! lss %linenum1% echo,%%a
- if !n! gtr %linenum2% echo,%%a
- ))>new_%%i
- move "new_%%i" "%%i"
- )
- pause
复制代码
|