Modify Text file

Hello,
I am trying to create a batch file that will modify a text file by pre-pending an existing value with several numbers.

For example:
The file has an entry called StoreID=97882

I would like the batch command to open the file, find the StoreID= and add four numbers in front of the existing numbers

Before: StoreID=97882

After: StoreID=555597882


Thank You for any help
RHoover673Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

chaauCommented:
Are you sure you want to do this with the batch file. VBS script will be much easier
0
KimputerCommented:
Even notepad is faster
Search StoreID=
Replace StoreID=5555
0
RHoover673Author Commented:
VBS is fine, can you provide example?
Thank You
0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

KimputerCommented:
Vbscript:

Const ForReading = 1
Const ForWriting = 2

strFileName = "c:\text.txt"
strOldText = "StoreID="
strNewText = "StoreID=5555"

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(strFileName, ForReading)

strText = objFile.ReadAll
objFile.Close
strNewText = Replace(strText, strOldText, strNewText)

Set objFile = objFSO.OpenTextFile(strFileName, ForWriting)
objFile.WriteLine strNewText
objFile.Close
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
RHoover673Author Commented:
Thank You, but the issue is that I need to keep the existing number and add the new 5555 to the beginning of the existing number


Before: StoreID=97882

After: StoreID=555597882


apologies if I was not clear
0
KimputerCommented:
Apparently you didn't try the code, otherwise you would see that everywhere it would change exactly as you described?
0
TommySzalapskiCommented:
That is what that will do, if you replace StoreID= with StoreID=5555, then StoreID=97882 will become StoreID=555597882.

I also agree that you don't need code to do this. Any text editor worth having has a find/replace feature.
0
RHoover673Author Commented:
Thank You
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming

From novice to tech pro — start learning today.