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

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
  • Recently Browsing   0 members

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