Batch processing of text alignment

Time:2020-7-31

For example, 1.txt is as follows. Copy content to clipboard code:
11111111111111111111198912 Zhang San
222222222222222222222150020 Li sisi
333333333333333333333333 360000 Wang Wu
4444444444444444442332 Zhao Liuliu
555555555555555555 222 tianqi
66666666666666666666666666669999 dance bar output through batch processing: copy content to the clipboard code:

11111111111111111111198912 Zhang San
222222222222222222222150020 Li sisi
333333333333333333333333 360000 Wang Wu
4444444444444444442332 Zhao Liuliu
555555555555555555 222 tianqi
66666666666666666666666666669999 dance bar code requirements, do not generate any temporary files.
Code concise, depending on ideas and code bonus!
——————————————————————————————
This problem is only to give a simple text, through batch processing typesetting, and require the general code, as Batman moderator said, will be a cumbersome process, so the problem-solving, do not need to consider the general code.
Silence:

Copy codeThe code is as follows:
@echo off
Setlocal Enabledelayedexpansion
set n=0
for /f “tokens=1,2*” %%i in (1.txt) do (
set “ke=%%i %%j”
set m=0
call :1
)
for /f “tokens=1,2*” %%i in (1.txt) do (
set “ke1=%%i %%j”
set ke2=%%i
set m1=0
call :2
echo !ke2! %%j %%k
)
pause
goto :eof
:1
if not “!ke:~%m%,1!”==”” set /a m+=1&goto 1
if %m% gtr %n% set n=%m%
goto :eof

:2
if not “!ke1:~%m1%,1!”==”” set /a m1+=1&goto 2
set /a dd=n-m1
for /l %%a in (1,1,%dd%) do set “ke2=!ke2! ”
goto :eof

 

 

batman:

Copy codeThe code is as follows:
@echo off&setlocal enabledelayedexpansion
set “kong= ”
for /f “delims=” %%a in (1.txt) do (
for %%i in (%%a) do (
set “str=%%i”&set /a n+=1
if !n! equ 2 (
set “str=%kong%!str!”
set /p=!str:~-10! <nul
) else (
set “str=!str!%kong%”
set /p=!str:~,20! <nul
))
set “n=0″&echo.
)
pause>nul

 

more:

Copy codeThe code is as follows:
@echo off
setlocal enabledelayedexpansion
for /f “tokens=1,2*” %%a in (‘type temp.txt’) do (
set “mo=%%a”&set “niu=%%b”&set “m=0″&set “n=0″&set “very=”
call :ming0 %%a %%b %%c
)
echo.&pause&exit
:ming0
if not “!mo:~%m%,1!”==”” (set “momo=!mo:~%m%,1!”&set /a “m+=1″&goto :ming0)
:ming1
if not “!niu:~%n%,1!”==”” (set “niuniu=!niu:~%n%,1!”&set /a “n+=1″&goto :ming1)
set /a “ming=30-%m%-%n%”
for /l %%i in (1 1 %ming%) do set “very=!very! ”
echo %1 %very% %2 %3

 

523066680:

Copy codeThe code is as follows:
@echo off
mode con cols=100 lines=20
setlocal enabledelayedexpansion
for /l %%a in (1,1,80) do set kong= !kong!
for /f “eol= tokens=1,2,3” %%a in (‘type 1.txt’) do (
set lie1-2=%%a%%b%kong%
set lie1-2=!lie1-2:~0,80!
set lie1-2=%%a!lie1-2:%%a%%b=!%%b
echo,!lie1-2! %%c
)
pause

Principle: for example, the text content is:
ab******1*d
abc*************2********e
Use for to get the first two columns
Direct combination eliminates the space in the middle
ab1
abc2
Add 80 spaces directly
ab1***************************……
abc2***************************……
Then save the first 80 bits.
ab1*********……***
abc2********……***
Move space forward
ab*********……***1
abc********……***2
So the front one is basically aligned. The third column is needless to say
I think it should be At least I can’t use it myself. I haven’t used this code as a tool