# Batch File To Read And Modify Text File



## Hashim1 (Nov 20, 2011)

Okay, so basically, I have a whole list of links in a plain text Notepad file, each link on a seperate line. All I am wanting to do is to add a bit of text before each link, specifically: 127.0.0.1 and a couple of spaces.

So this...


```
[SIZE=3]somelink.com[/SIZE]
```
becomes this...


```
[SIZE=3]127.0.0.1     somelink.com[/SIZE]
```
By now you've probably already guessed what I'm trying to do here and what it's for. 

So I am wanting some batch file code, executable in a .bat file, which basically reads a Notepad text file, and then add "127.0.0.1 " at the beginning of each line with text on it. I am guessing this is probably a very simple piece of code for someone with some knowledge of MS DOS and batch file code, but that most certainly isn't me, and the only batch files I have ever written have been with help like now.

Thanks for any and all help in advance with this, much appreciated.


----------



## Squashman (Apr 4, 2003)

Seems like this would take two seconds to accomplish in Excel.


----------



## Hashim1 (Nov 20, 2011)

I'm not understanding you, how would Excel help me to edit a Notepad file?


----------



## Squashman (Apr 4, 2003)

You are confused on what your file is. Your file is not a notepad file it is a text file. Excel has no problems opening a text file. When you open it with excel it will put all of your text file into one column. Add a column before it and put your Local host address in the first column and then resave the file.


----------



## Hashim1 (Nov 20, 2011)

Ah yes, I see what you mean now. That is a very useful way to do it. Thanks for that, could be very useful for future reference. 

However, in this case, I'd like to actually know how to do it via a batch file regardless. Thanks anyway though.


----------



## Squashman (Apr 4, 2003)

Simple one line of code using the FOR command


----------



## Hashim1 (Nov 20, 2011)

Using a batch file? Could you give me the code please, I have no past experience in writing MS-DOS/batch-file code whatsoever.


----------



## ahowtoupda (Feb 6, 2012)

I am having the same issue,I was google it for a long time but I still don't know what to do,I hope it can help here!


----------

