Find and replace not working in batch scrpt -


i'm trying make batch script find , replace option batch script doesn't instead show blinking cursor , gets stuck there.

here's coding im using:

setlocal set this=abhinav2  /f "delims=" %%i in ('^<test\abc.new findstr /n "^"') ('     set "line=%%i"     setlocal enabledelayedexpansion     set "line=!line:*:=!"     if not "!line!"=="!line:<xyz>mnishamk<abc>" set "line=<xyz>%this%<abc>"     (echo(!line!)>>test\new.abc     endlocal ) ) 

i can't replace mnishamk abhinav2 there lots of names mnishamk present in file. i'm newbie this. please help!

thanks, aj

you have syntax issue, see set /? , try this:

@echo off&setlocal enabledelayedexpansion set "line=<xyz>mnishamk<abc>" set "this=abhinav2"  if not "!line!"=="!line:<xyz>mnishamk<abc>=!" set "line=<xyz>%this%<abc>" echo !line! 

output is:

<xyz>abhinav2<abc> 

and works:

set "line=!line:<xyz>mnishamk<abc>=<xyz>%this%<abc>!" 

Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -