?
Solved

Simple batch script to multiply text file entries

Posted on 2011-10-19
3
Medium Priority
?
477 Views
Last Modified: 2012-05-12
I would like help in creating the following batch script:

Script takes input from "input.txt". Sample input content below:

A
B
C
D
E
F
.
.
.
n

Since the file has "n" entries (not fixed number), the batch will require to read each line in the input, one by one.

At the end, the batch script writes to "output.txt" each line from "input.txt" in a multiple "x" amount defined inside the script. For example, if x = 5 then "output.txt" will contain:

A
A
A
A
A
B
B
B
B
B
.
.
.
.
.
.
.
n
n
n
n
n

Sample input.txt and output.txt (for x=5) are attached.

Thank you!
 Temp.zip
0
Comment
Question by:Barbulescu
  • 2
3 Comments
 
LVL 43

Accepted Solution

by:
Steve Knight earned 2000 total points
ID: 36993225
Presumably in real life how big is this, and does the order matter?  If not you could do:

copy input.txt + input.txt + input.txt out.txt
sort out.txt > output.txt

or otherwise process line by line:

@echo off
set input=input.txt
set output=output.txt
set times=5
(for /f "delims=" %%a in ('type %input%') do for /l %%C in (1,1,%times%) do echo %%a) > %output%
notepad %output%
0
 

Author Closing Comment

by:Barbulescu
ID: 36993366
Thank you for your support.
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 36993379
no problem, glad it helped.
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

YESTERDAY YESTERDAY.BAT is inspired by a previous article I wrote entitled: TOMORROW.BAT (http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/MS_DOS/A_4196-Advanced-Batch-File-Programming-TOMORROW-BAT.html). The crux of this batch f…
Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question