James Roseman
James Roseman

Reputation: 1624

Copying text file to another text file line by line?

Part 1

I'm trying to read a text file and then copy into another text file line by line.

Here's what I've got so far:

@echo off

for /f %%A in (input.txt) DO (
    for /f %%B in (output.txt) DO (
        echo %%A > output.txt
    )
)

It runs, but only puts the last line from input.txt into output.txt, while I want each line written. Any thoughts?

My Main Project

My main project is to take the following input:

input.txt
/fruits-and-veggies/oranges
/fruits-and-veggies/brussel-sprouts
/fruits-and-veggies/apples
/fruits-and-veggies/passion-fruit
/fruits-and-veggies/broccoli

And then analyze them for the tag <h1>Fruit!</h1> and then compile the links that do contain them in the following output:

/fruits-and-veggies/oranges
/fruits-and-veggies/apples
/fruits-and-veggies/passion-fruit

Take these to be subdirectories to the website http://www.example.com .

I know I'll need to use FINDSTR and a for loop, but I'm not sure how to go about the batch file actually going into the HTML.

Upvotes: 1

Views: 842

Answers (1)

Whetstone
Whetstone

Reputation: 1199

Switch to append >> instead of write >. You're overwriting your file every time you write.

Upvotes: 2

Related Questions