# Solved: Read values from txt to output txt



## fscldhppr (Mar 29, 2010)

I have a text file with paired items that I wish to place(in order)within a second text file(to be created)which will include the other data lines(shown in output file).

Example:

(input file1.txt)


```
[COLOR=Red]apples pears[/COLOR]
[COLOR=Blue]oranges peaches[/COLOR]
[COLOR=Green]grapefruit plums[/COLOR]
```
etc...(1000+ lines to be processed)

(output file2.txt)


```
This is todays stock="fruit"(place "[COLOR=Red]apples[/COLOR]" here)
This is tomorrows order="fruit"(place "[COLOR=Red]pears[/COLOR]" here)
In stock="fruit"(place "[COLOR=Red]apples[/COLOR]_[COLOR=Red]pears[/COLOR]" here)

This is todays stock="fruit"(place "[COLOR=Blue]oranges[/COLOR]" here)
This is tomorrows order="fruit"(place "[COLOR=Blue]peaches[/COLOR]" here)
In stock="fruit"(place "[COLOR=Blue]oranges[/COLOR]_[COLOR=Blue]peaches[/COLOR]" here)

This is todays stock="fruit"(place "[COLOR=Green]grapefruit[/COLOR]" here)
This is tomorrows order="fruit"(place "[COLOR=Green]plums[/COLOR]" here)
In stock="fruit"(place "[COLOR=Green]grapefruit[/COLOR]_[COLOR=Green]plums[/COLOR]" here)
```
etc....

Any help appreciated, thank you.


----------



## Squashman (Apr 4, 2003)

```
@echo off
IF exist file2.txt del file2.txt
FOR /F "tokens=1,2 delims= " %%G in (file1.txt) do (
	echo This is todays stock="fruit"(place "%%G" here^)
	echo This is tomorrows order="fruit"(place "%%H" here^)
	echo In stock="fruit"(place "%%G_%%H" here^)
)>>file2.txt
```
Output

```
This is todays stock="fruit"(place "apples" here)
This is tomorrows order="fruit"(place "pears" here)
In stock="fruit"(place "apples_pears" here)
This is todays stock="fruit"(place "oranges" here)
This is tomorrows order="fruit"(place "peaches" here)
In stock="fruit"(place "oranges_peaches" here)
This is todays stock="fruit"(place "grapefruit" here)
This is tomorrows order="fruit"(place "plums" here)
In stock="fruit"(place "grapefruit_plums" here)
```


----------



## fscldhppr (Mar 29, 2010)

Works perfect Squashman, thank you.


----------



## Squashman (Apr 4, 2003)

Your Welcome.
Please stick around the forums and help others.


----------

