4

I have a long list where each line reads

p1 Title 1
p24 Title 2
p84 Title 3
...

I need each file to be prepended with a simple string, the initials of the book like so.

MB.p1 Title 1
MB.p24 Title 2
MB.p84 Title 3
...

I have tried the tips on Batch file to add characters to beginning and end of each line in txt file and How do you loop through each line in a text file using a windows batch file?

Community
  • 1
  • 1
Paul H
  • 901
  • 2
  • 7
  • 12

1 Answers1

2

In my case I found that the easiest way was to use a combination of the two links posted above:

for /f "tokens=*" %a in (input.txt) do (echo MB.%a) >> output.txt
Paul H
  • 901
  • 2
  • 7
  • 12
  • 1
    Your answer is practically the same than the accepted answer of your first link: `for /f "tokens=*" %a in (input.txt) do (echo "%a">> output.txt)`, so IMHO you shouldn't wasted an SO question/answer just to post this "solution", specially if you already solved your problem _before_ posted the question... – Aacini Sep 26 '15 at 23:01
  • Oh, I understand the reason now. _All_ [your 6 answers](http://stackoverflow.com/users/2582691/paul-h?tab=answers) in this site are answers _to your own questions_! This is a strange way to accumulate activity and rep points... – Aacini Sep 26 '15 at 23:21
  • 2
    There is nothing inherently wrong with answering your own question, but it better be a novel question and answer that makes a significant contribution to the SO collective knowledge base. As Aacini points out, this is nearly identical to the existing posted answers. Plus there are a gazillion existing Q&As regarding editing text files with batch. This Q&A offers nothing that has not already been covered. – dbenham Sep 27 '15 at 20:39