怎样用bat分割txt文档?
答案:1 悬赏:40 手机版
解决时间 2021-05-09 04:50
- 提问者网友:送舟行
- 2021-05-08 21:43
怎样用bat分割txt文档?
最佳答案
- 五星知识达人网友:山河有幸埋战骨
- 2021-05-08 22:31
@echo off
set /a n=101600,kb=n
set "临时文件=tmp.txt"
set /p file=请把要处理的文件拖到此处:
set "file=%file:"=%"
cls&echo 正在分割 %file% 文件请稍候。。。
for /f "delims=" %%a in ("%file%") do set wjm=%%~na
findstr /no ".*" "%file%">"%临时文件%"
for /f "tokens=2 delims=:" %%a in ('find /c /v "" "%临时文件%"') do set /a z=%%a
if not exist "%wjm%\" md "%wjm%"
:list
set /a x+=1
if defined t >>"%wjm%\%wjm%_%x%.txt" echo %t%
set "t="
if not defined h (set skip=) else (set skip=skip=%h%)
setlocal enabledelayedexpansion
for /f "%skip% tokens=1,2* delims=:" %%a in (%临时文件%) do (
if %%b geq !kb! set /a kb+=n&set flag=a&goto loop
set /a g+=1
set !g!=%%c&set /a h=%%a,u=%%a
)
:loop
if not defined flag (
if defined t >>"%wjm%\%wjm%_%x%.txt" echo %t%
for /l %%a in (1 1 !g!) do >>"%wjm%\%wjm%_%x%.txt" echo.!%%a!
goto end
)
set "var=!%g%!"
if not defined var set /a g-=1,h-=1&goto loop
for /f "tokens=1* delims=。" %%a in ("!var!") do (
if "!var!"=="%%a" set /a g-=1,h-=1&goto loop
if not "%%b"=="" set "t=%%b"
set w=%%a。
)
for /l %%a in (1 1 !g!) do >>"%wjm%\%wjm%_%x%.txt" echo.!%%a!
>>"%wjm%\%wjm%_%x%.txt" echo !w!
endlocal&set h=%h%&set t=%t%&set kb=%kb%&set "u=%u%"
if %u% neq %z% goto list
:end
del/q "%临时文件%" 2>nul
start "" "%wjm%"
set /a n=101600,kb=n
set "临时文件=tmp.txt"
set /p file=请把要处理的文件拖到此处:
set "file=%file:"=%"
cls&echo 正在分割 %file% 文件请稍候。。。
for /f "delims=" %%a in ("%file%") do set wjm=%%~na
findstr /no ".*" "%file%">"%临时文件%"
for /f "tokens=2 delims=:" %%a in ('find /c /v "" "%临时文件%"') do set /a z=%%a
if not exist "%wjm%\" md "%wjm%"
:list
set /a x+=1
if defined t >>"%wjm%\%wjm%_%x%.txt" echo %t%
set "t="
if not defined h (set skip=) else (set skip=skip=%h%)
setlocal enabledelayedexpansion
for /f "%skip% tokens=1,2* delims=:" %%a in (%临时文件%) do (
if %%b geq !kb! set /a kb+=n&set flag=a&goto loop
set /a g+=1
set !g!=%%c&set /a h=%%a,u=%%a
)
:loop
if not defined flag (
if defined t >>"%wjm%\%wjm%_%x%.txt" echo %t%
for /l %%a in (1 1 !g!) do >>"%wjm%\%wjm%_%x%.txt" echo.!%%a!
goto end
)
set "var=!%g%!"
if not defined var set /a g-=1,h-=1&goto loop
for /f "tokens=1* delims=。" %%a in ("!var!") do (
if "!var!"=="%%a" set /a g-=1,h-=1&goto loop
if not "%%b"=="" set "t=%%b"
set w=%%a。
)
for /l %%a in (1 1 !g!) do >>"%wjm%\%wjm%_%x%.txt" echo.!%%a!
>>"%wjm%\%wjm%_%x%.txt" echo !w!
endlocal&set h=%h%&set t=%t%&set kb=%kb%&set "u=%u%"
if %u% neq %z% goto list
:end
del/q "%临时文件%" 2>nul
start "" "%wjm%"
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯