本帖最后由 qixiaobin0715 于 2024-7-18 12:54 编辑
这样可能要美观一些:- @echo off
- for /f "tokens=1-3" %%i in (a.txt) do (
- echo,%%i>>temp1
- echo,%%j>>temp2
- )
- set /a n1=n2=0,y1=y2=0
- setlocal enabledelayedexpansion
- for %%a in (1 2) do (
- echo,a>>temp%%a
- for /f "delims=:" %%i in ('findstr /o .* temp%%a') do (
- set /a x%%a=%%i-y%%a
- if !n%%a! lss !x%%a! set /a n%%a=x%%a
- set y%%a=%%i
- )
- del temp%%a
- set /a n%%a+=4
- for /l %%i in (1,1,!n%%a!) do set BS%%a= !BS%%a!
- )
- (for /f "tokens=1-2*" %%i in (a.txt) do (
- if "%%j"=="" (set f1=%%i) else (set f1=%%i!BS1!&set f1=!f1:~,%n1%!)
- if "%%k"=="" (set f2=%%j) else (set f2=%%j!BS2!&set f2=!f2:~,%n2%!)
- set f3=%%k
- echo,!f1!!f2!!f3!
- ))>b.txt
- pause
复制代码
|