Jump to content

Recommended Posts

Posted

I need to be able to loop through a text file, find a line and replace it. I know that I can use FOR /F, but how do I actually do the compare and replace. Is it possible in a batch file or should I just use VBS?


Posted

Okay, it was too easy to do it in vbs. Although if someone could explain how to do it in batch, I'd love to hear it.

Posted

without using third party software like SED you would use for /f and wite all of the line to another file and do an if statement to look for the line you want to change and replace it when writeing then copy over the original file wh=ith the modified when finished.

for /f %%L in (%svcpackdir%\HFINT.DAT) DO (
if %%L==mrxsmb.sys.temp (
echo mrxsmb.sys>>%svcpackdir%\HFINT.TMP
) ELSE (
echo %%L>>%svcpackdir%\HFINT.TMP
)
)
move /y %svcpackdir%\HFINT.TMP %svcpackdir%\HFINT.DAT

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...