本帖最后由 tkaven 于 2012-3-20 18:26 编辑
| @echo off&color a&setlocal enabledelayedexpansion | | ::用法 call :insert "要修改的本文文档路径" "在哪一行下面插入文字" "所要插入的文字" | | call :insert "C:\Users\Administrator\Desktop\新建 Text Document.txt" "5" "我好喜欢你啊,哈哈哈" | | endlocal | | echo 操作完成,按任意键退出&pause>nul | | exit | | | | :insert | | FOR /F %%l in ('find /c /v ""^< %1') do ( | | for /l %%a in (1 1 %%l) do ( | | set /p str= | | set /a 当前行=当前行+1 | | if !当前行! GTR %~2 ( | | echo.!str! | | ) else ( | | if !当前行! EQU %~2 (echo.!str!&echo.%~3) else (echo.!str!) | | ) | | set str= | | ) | | )< %1 >> "%~d1%~p1%~n1_已处理%~x1" | | goto :eofCOPY |
|