@echo off
setlocal enabledelayedexpansion
:: 设置输入文件名
set "input=input.txt"
set /a maxlines=20000
:: 获取当前日期作为文件夹名(格式:YYYY-MM-DD)
for /f %%i in ('powershell -NoProfile -Command "Get-Date -Format yyyy-MM-dd"') do set "datedir=%%i"
:: 创建日期文件夹
if not exist "%datedir%" mkdir "%datedir%"
:: 初始化计数
set /a linecount=0
set /a filecount=1
set "outfile=%datedir%\part!filecount!.txt"
:: 读取并分割文件
(for /f "usebackq delims=" %%A in ("%input%") do (
set /a linecount+=1
echo %%A>>"!outfile!"
if !linecount! geq %maxlines% (
set /a filecount+=1
set /a linecount=0
set "outfile=%datedir%\part!filecount!.txt"
)
))
echo 完成!文件已保存至 "%datedir%" 文件夹中。
pause
文章评论