提供另一个思路,未编辑为小函数。假设跳过3行,读取5行,源文件为a.txt,修改后的文件为new_a.txt,处理过程使用了临时文件a.log,执行结束后del:- @echo off
- setlocal enabledelayedexpansion
- set x=3
- set y=5
- set /a z=x+y
- (for /l %%a in (1,1,%z%) do (
- set /p str=
- echo,!str!
- ))<a.txt>a.log
- (for /f "skip=%x% delims=" %%i in (a.log) do echo,%%i)>new_a.txt
- del a.log
- pause
复制代码
|