用bat批处理对txt文本进行分割
发布网友
发布时间:2022-04-23 08:57
我来回答
共2个回答
热心网友
时间:2022-06-18 17:19
@echo off & title 分割文本 By 依梦琴瑶
setlocal enabledelayedexpansion
::设置要分割的文件
set file=test.txt
for /f "delims=" %%a in ('type "%file%"') do (
echo "%%~a" | findstr ^"\^> >nul && (
for /f "tokens=2 delims=> " %%b in ('echo "%%~a"') do set "txt=%%~b.txt"
) || (
(echo %%~a)>>"!txt!"
)
)
pause
热心网友
时间:2022-06-18 17:19
@echo off
set "file=a.txt"
powershell "[int]$n=$c=0;$a='%file%';[string[]]$s=gc $a;$r=($s -split '<.+')|foreach{if($_ -eq ''){$n+=1}else{$_|Out-File -Append([string]($n)+'.txt')}};dir *.txt|ren -NewName{if($_.Name -ne $a){$script:c++;[string]($c)+'.txt'}}-Force -ErrorAction Ignore"
echo ok;
pause