modify a text file with another text file

September 7, 2011 at 02:41:30
Specs: Windows 7
hi, I have two files.

file1.txt contains:

file2.txt contains:

I like to modify file2.txt use file1.txt becomes:
file2.txt contains:

so, writing in file2.txt good1 replaced with the words:
of file1.txt

please advice my friends here. thanks

See More: modify a text file with another text file

Report •

September 7, 2011 at 17:27:17
Why this demand for batch files?

Report •

September 7, 2011 at 21:50:20
batch files? because it is a simple programming for my simple task

Report •

September 8, 2011 at 16:17:52
try this:

@echo off

findstr 1 file1.txt >> file3.txt
findstr 2 file1.txt >> file3.txt

findstr 2 file2.txt >> file3.txt
findstr 3 file2.txt >> file3.txt

it does not merge the two but instead create another file with the desired output. Hope it helps

Report •

Related Solutions

September 9, 2011 at 00:55:24
hi crashnburn99,
Thanks for your answer..
how if the file2.txt has unknown count of line ?
i hope your best answer. tks

Report •

September 9, 2011 at 00:56:30
i mean the file2.txt has unknown total of lines

Report •

September 9, 2011 at 08:35:24
Well the code above is not really based on lines. It is based on the variable. For example the findstr 1 will pull any string with 1 in it throughout the document. So if there is any sort of common variable in multiple documents that you are looking for, replace the 1, 2, & 3 with the desired variable. You can also add in options after findstr to help narrow it down:

/I Case-insensitive search.
/S Search subfolders.
/P Skip any file that contains non-printable characters

/L Use search string(s) literally.
/R Use search string(s) as regular expressions.(default)

/B Match pattern if at the Beginning of a line.
/E Match pattern if at the END of a line.

/X Print lines that match exactly.
/V Print only lines that do NOT contain a match.
/N Print the line number before each line that matches.
/M Print only the filename if a file contains a match.
/O Print character offset before each matching line.
/a color_attribute Display filenames in colour (2 hex digits)

I hope this kind of answers your question, if not let me know and we will try to narrow it down

Report •

September 12, 2011 at 01:54:32
Hi crashnburn99,
thanks 4 ur best answer...i find a solution using ur advice...
u r a best friend..

Report •

September 12, 2011 at 13:23:01
Glad I could help

Report •

Ask Question