Edit a line through BATCH scripting

I am creating a .BAT file.In that I have opened a file(.DAT).
How can I edit a line in that opened file through BATCH SCRIPT.

What command I should use ?

Eg : I have a line in the opened  file as " SERIAL_NUMBER :100"
I want to change the value 100 to 101  as after change the line should looks like

Here 100 and 101 are coming as parameters.

Please give a solution .

Thanks in advance

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

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.

Renato Montenegro RusticiIT SpecialistCommented:
User Windows Scripting.

1) Open a file for read and another for write.
2) Use the replace method to replace the string.
3) Output to the temp file (the write file)
4) Close both files
5) Delete the original file or change its extension (like bak)
6) Rename the temp file to the production name

Your are done.

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
It can be done in a batch file ...

The process is to simply read in the file one line at a time. If the line matches the search criteria, then output the replacement string to a temporary file — otherwise, if it doesn't match the search criteria, output a copy of the input line to the temporary file.
Then simply replace the input file with the temporary file.

@Echo OFF
Setlocal EnableDelayedExpansion
:# Variables
Set InputFile=filename.dat
Set TempFile=temp.txt
Set Search=SERIAL_NUMBER :100
Set Replace=SERIAL_NUMBER :101
:# Perform the operations
For /F "delims=" %%I In (%InputFile%) Do Call :Process "%%~I"
Del /F %InputFile% >Nul
Ren "%TempFile%" "%InputFile%" >Nul
:# Done.
Exit /B
Set Line=%~1
If /i "%Line%" == "%Search%" (
    Echo %Replace%>>%TempFile%
) ELSE (
    Echo %Line%>>%TempFile%
Exit /B
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
Multimedia Programming

From novice to tech pro — start learning today.