Concatenate adjacent odd/even Line Text Content

Source: Internet
Author: User

CopyCode The Code is as follows: @ echo off
Goto run

The problem is that there is a text file with the following content:
Accident
N. accidents, accidents; accidents (factors)
Across
Prep. Crossed, crossed; opposite ad. Crossed, crossed
Active
Active, agile, and active; active
Advertise
Vt. Announcement, announcement; advertisement for... vi. Advertisement
After
Prep. In... later; In... after adv. Later
How can I put it in another file with the following content:
Accident N. accidents, accidents; accidents (factors)
Across prep. Crossed, crossed; crossed across ad. Crossed, crossed
Active. Active, agile, and active.
Advertise vt. Announcement; advertisement for... vi. Advertisement
After prep. After...; after adv. After

General Solution:
@ Echo off
: Code by JM 2006-9-21 cmd @ XP
Set/a num = 1
Setlocal enabledelayedexpansion
For/F "tokens = *" % I in (1.txt) Do (
Set/a num + = 1
Set/A mod =! Num! % 2
If! Mod! Equ 1 (set Var = % I) else (set STR = % I)
If! Mod! Equ 1 echo! Str! ! VaR!
)
Pause
Goto: EOF

The simplest and most efficient solution:
: Run
@ Echo off
: Code by 3742668 2006-9-21 cmd @ XP
Setlocal enabledelayedexpansion
For/F "delims =" % I in (1.txt) Do (
If "! Str! "=" "(Set STR = % I
) Else (
Echo! Str! % I
Set STR =
)
)
Pause

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.