Copy specific text to another file's line

Microsoft WINDOWS XP
December 12, 2009 at 08:14:18
Specs: Windows XP, C2D/2GB
I have 2 text files, A.txt and B.txt.
Some text in file A (Bold) is veriable, and can be changed.
file A.txt contain:
1. ----------------first line fixed.------.
2.-------2nd fixed line- \\abcd\abcd\abcd\3061_2009-11-06_17-00-00_1.
3. "\AB.CDEF02.1234" | 0 | Aaaaa aa A | 091106-111111 |

File B contains: (all fixed except WXYZ and WXYZ_0000000_111111):
Now, I want to replace 4389 in file B, with 1234 from 3rd line of file A and
165642 in file B, with 11111 from file A, randomly (If the contains of file A.txt
changes, contains of file B.txt should be changed after Batch process..)

Please help ...

See More: Copy specific text to another files line

Report •

December 15, 2009 at 15:19:58
That looks .. complicated. Can you rephraze the question ?

Report •

December 16, 2009 at 00:58:23
@echo off && setlocal enabledelayedexpansion
for /f "skip=2 tokens=3,7 delims=|.-" %%a in (dat) do (
set bb=%%b
set aa=%%a
set aa=!aa:~0,-2!
set ab=!aa!_!bb:~0,-1!
call :BB )
goto :EOF

set /a ct=0
For /f "tokens=* delims=" %%z in (dat2) do (
set line=%%z
set /a ct+=1
if !ct! equ 4 (
for /f "tokens=3,9 delims=.," %%c in ("!line!") do (
set cc=%%c
set cd=%%d
call :blew )
echo !line! >> outfile )
goto :EOF

set line=!line:%cc%,=%aa%,!
set line=!line:%cd%=%ab%!


Report •

December 19, 2009 at 00:57:37
->I have 2 files A.txt and B.txt.
->File A.txt has 3 lines while file B.txt has 6 lines.
->File B.txt is a command file n has a script in line 4.
->I have to edit two contents of line 4 (B.txt) manually. they are
at the position of 4389 and 4389_165642.

->The raw data i collect from 3rd line of file A.txt
from the position of 1234 and 111111

->3rd line of file A is started with a space

->They two contains of 3rd line(file A) changes at every 15 min.

So I want a batch file that copy these 2 contains from 3rd line of file
A.txt and paste to the script in line 4 of file B.txt

Please help...

Report •

Related Solutions

December 19, 2009 at 01:03:22
line numbers are for reference only

Report •

December 19, 2009 at 04:52:36
sorry sir, something crapped in my transfer of code, make change in "BB:" subroutine, move the echo out to the last
parenthesis, so it looks like:
set /a ct=0
For /f "tokens=* delims=" %%z in (dat2) do (
set line=%%z
set /a ct+=1
if !ct! equ 4 (
for /f "tokens=3,9 delims=.," %%c in ("!line!") do (
set cc=%%c
set cd=%%d
call :blew )
echo !line! >> outfile )

one of these days i'll get it right, then the world will indeed end.

Report •

December 19, 2009 at 06:39:15
Still not working......


Do u required more information?

Please let me know.

Report •

December 19, 2009 at 12:33:20
yes, because it works on my end of the line. I'm using the data you gave in original post as inputs, filenames dat (for
the 3-line file) and dat2 (the 6-line file). using xp pro sp2

1) what are the actual names of the input files you're using to test (esp. if they contain that nasty space. I've already had way too many issues with that!)
2) what is exact test data in the files
3) what if any error message(s) do you get
4) what, if anything, appears in the output file

Report •

December 21, 2009 at 02:36:45
Can I attach those files ?

Report •

December 21, 2009 at 12:14:40
should not need to attach, as the data requested should not be real large. you said file A was only 3 lines and B was 6 lines. I'm just using the exact data you gave in the original post, word for word except for removing the line-numbers, so if it's the same, no need to include that. You can send the info via private-mail if you want. as of now, I'm flying blind, "flailing around", shooting in the dark... I'll help if i can but i'm grid-locked at this point.

Report •

December 22, 2009 at 04:18:32

When I run this batch file nothing happens.
It creates only one file named "output".

If u wish to provide your mail id, I can mails those file to you,
Then solution will be very easy for you.


Report •

Ask Question