- @echo off
- setlocal EnableDelayedExpansion
- cd /d "%~dp0"
- set /p var1=要切割的行数:
- set /p var2=要生成最大文本数:
- set src=1.txt
- set linectr=0
- set filectr=0
-
- for /f "delims=" %%A in (%src%) do (
- if !linectr! equ 0 (
- set /a filectr+=1
- if !filectr! gtr %var2% goto break
- echo %%A>"txt!filectr!.txt"
- ) else (
- echo %%A>>"txt!filectr!.txt"
- )
- set /a linectr+=1
- if !linectr! geq %var1% set linectr=0
- )
-
- :break
- endlocal
- pause
复制代码
|