本帖最后由 aloha20200628 于 2024-12-6 16:37 编辑
回复 1# meiszp
再给一个批处版本- @echo off &setlocal
- (for /f "delims=" %%s in (1.txt) do set "b=%%s" &call :xxx)>2.txt
- endlocal&pause&exit/b
- :xxx
- for /f "tokens=1* delims=:" %%a in ("%b%") do (set "a=%%a"&set "b=%%b")
- if "%a:~-1%"=="码" (set/p="%a%:%b:~,4%"<nul&echo,&set "b=%b:~5%") else (set/p="%a%:"<nul)
- if "%b%"=="" (exit/b) else goto :xxx
复制代码 若源文件 1.txt 是utf-8编码,以上代码第一行须改为如下行,且脚本代码亦须改存为utf-8编码...- @echo off &chcp 65001>nul &setlocal
复制代码
|