用第三方工具会快得多...- @echo off
- Setlocal Enabledelayedexpansion
- set "src_fl=a.txt"
- set "dst_fl=b.txt"
- type nul>"%dst_fl%"
- for /f "delims=" %%a in (%src_fl%) do (
- call :lp "%%a"
- >>"%dst_fl%" echo.
- )
- start "" "%dst_fl%"
- goto :eof
- :lp
- for /f "delims=, tokens=1,*" %%i in ("%~1") do (
- set "var=%%i"
- if "!var:~,1!"=="b" (
- >>"%dst_fl%" set /p=""!var!""<nul
- >>"%dst_fl%" set /p=,<nul
- ) else (
- if "!var:~-1!"=="b" (
- >>"%dst_fl%" set /p=""!var!""<nul
- >>"%dst_fl%" set /p=,<nul
- ) else (
- >>"%dst_fl%" set /p=!var!,<nul
- )
- )
- call :lp "%%j"
- )
复制代码
|