Batch processing of text-left alignment typesetting _dos/bat

Source: Internet
Author: User
such as 1.txt content as follows. Copy content to Clipboard code:
111111111111111111111 98912 Zhang Three
222222222222222222 150020 Lee 44
333333333333333333333 360000 Harry
444444444444444444 2332 Zhao 66
555555555555555555 222 Tianqi
666666666666666666666, 999999 dances. Output from batch processing to: Copy content to Clipboard code:

111111111111111111111 98912 Zhang Three
222222222222222222 150020 Lee 44
333333333333333333333 360000 Harry
444444444444444444 2332 Zhao 66
555555555555555555 222 Tianqi
666666666666666666666 999999 Dance Bar code requires that no temporary files are generated.
Code concise, depending on the idea and code bonus points!
------------------------------------------------------------------------------------------
The topic is only to give a simple text through batch layout, and the requirements of the general Code, as Batman moderator said, will be a tedious process, so on the problem, do not have to consider the general code.
Light default:
Copy Code code 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 Code code 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 Code code as follows:

@echo off
Setlocal enabledelayedexpansion
for/f "tokens=1,2*"%%a in (' Type temp.txt ') does (
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 Code code 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 ') does (
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 reads:
Ab******1*d
Abc*************2********e
Get the previous two columns with for
The direct combination eliminates the middle space:
Ab1
Abc2
Add 80 spaces directly
ab1*************************** ...
abc2*************************** ...
Then save the top 80 bits.
ab1*********......***
abc2********......***
Move the space forward
Ab*********......***1
Abc********......***2
So the front is basically aligned. The third column in the back is needless to say ...
I think it should be OK ... At least I'm not used to being too generic, and this code is not used as a tool.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.