I have some files that contain some of if not all of the following:
Program RxBIN RXPCN RxGroup MemberID
not all files will have all of those headers but the ones that do I will need to replace so it looks like this:
@Program @RxBIN @RXPCN @RxGroup @MemberID
Thanks in Advance,
Joe
(SOLVED) .bat Find and Replace text
Moderator: DosItHelp
(SOLVED) .bat Find and Replace text
Last edited by jmituzas on 31 Aug 2010 11:33, edited 1 time in total.
-
- Expert
- Posts: 442
- Joined: 01 Aug 2010 17:13
- Location: Canadian Pacific
- Contact:
Re: .bat Find and Replace text
It's not too hard to write the batch for that if those words aren't mixed in with a bunch of other data, since it would just require comparing 5 tokens to 5 words, but DOS needs to rewrite each file too. I'm betting on this being easier for gawk (ghostmachine), I'm too tired to write anything right now.
Re: .bat Find and Replace text
orange_batch wrote:It's not too hard to write the batch for that if those words aren't mixed in with a bunch of other data, since it would just require comparing 5 tokens to 5 words, but DOS needs to rewrite each file too. I'm betting on this being easier for gawk (ghostmachine), I'm too tired to write anything right now.
Thanks for the input... I am realizing that it is alot easier to come up with these kind of solutions in sed, awk, or even perl. But these are to be transfered to windows desktops, and I don't think that windows will interpret those without installing a 3rd party app to all the desktops in question.
Thanks anyways,
Joe
(SOLVED) .bat Find and Replace text
I found the solution http://www.dostips.com/?t=Batch.FindAndReplace
had to rewite it a bit to actually get the job done.
I am sure there is an easier way of doing this but I got it to work
call BatchSubstitute.bat Program @Program InDesignData.txt >newfile.txt
if not exist newfile.txt goto skip
del "InDesignData.txt"
ren "newfile.txt" "InDesignData.txt"
:skip
call BatchSubstitute.bat RxBIN @RxBIN InDesignData.txt >newfile.txt
if not exist newfile.txt goto skip
del "InDesignData.txt"
ren "newfile.txt" "InDesignData.txt"
:skip
call BatchSubstitute.bat RXPCN @RXPCN InDesignData.txt >newfile.txt
if not exist newfile.txt goto skip
del "InDesignData.txt"
ren "newfile.txt" "InDesignData.txt"
:skip
call BatchSubstitute.bat RxGroup @RxGroup InDesignData.txt >newfile.txt
if not exist newfile.txt goto skip
del "InDesignData.txt"
ren "newfile.txt" "InDesignData.txt"
:skip
call BatchSubstitute.bat MemberID @MemberID InDesignData.txt >newfile.txt
if not exist newfile.txt goto skip
del "InDesignData.txt"
ren "newfile.txt" "InDesignData.txt"
:skip
had to rewite it a bit to actually get the job done.
I am sure there is an easier way of doing this but I got it to work
call BatchSubstitute.bat Program @Program InDesignData.txt >newfile.txt
if not exist newfile.txt goto skip
del "InDesignData.txt"
ren "newfile.txt" "InDesignData.txt"
:skip
call BatchSubstitute.bat RxBIN @RxBIN InDesignData.txt >newfile.txt
if not exist newfile.txt goto skip
del "InDesignData.txt"
ren "newfile.txt" "InDesignData.txt"
:skip
call BatchSubstitute.bat RXPCN @RXPCN InDesignData.txt >newfile.txt
if not exist newfile.txt goto skip
del "InDesignData.txt"
ren "newfile.txt" "InDesignData.txt"
:skip
call BatchSubstitute.bat RxGroup @RxGroup InDesignData.txt >newfile.txt
if not exist newfile.txt goto skip
del "InDesignData.txt"
ren "newfile.txt" "InDesignData.txt"
:skip
call BatchSubstitute.bat MemberID @MemberID InDesignData.txt >newfile.txt
if not exist newfile.txt goto skip
del "InDesignData.txt"
ren "newfile.txt" "InDesignData.txt"
:skip