用大量临时文件的办法(不推荐),只对顶楼方案进行小改造,减少耗时的操作:- @echo off&setlocal enabledelayedexpansion
- set/p file=拖入需要修改的文件并回车:
- set/p src=拖入需要增加的文件并回车:
- set/p count=输入每隔多少行插入:
- set/p blank=输入插入多少行:
-
- md 临时文件夹
-
- for /f "delims=" %%i in ('type %src%')do (
- set/ai+=1
- (for /l %%b in (1 1 %blank%)do echo,%%i)>临时文件夹\!i!.txt
- )
-
- (for /f "usebackq delims=" %%a in (%file%) do (
- echo,%%a
- set/a n+=1,m=n%%count
- if !m! equ 0 (
- set/aj+=1,j=j%%i+1
- type 临时文件夹\!j!.txt
- )
- ))>new.txt
-
- rd /s /q 临时文件夹
-
- start new.txt
复制代码
|