Replacing Characters in String
Try this
setlocal set string=cat rat mat fatset string=%string:t=p%
You've got the =
sign in the wrong place. Try:
setlocal enabledelayedexpansionset /P MY_TEXT=ENTER TEXT:SET T2P=Pset NEW_TEXT=%MY_TEXT:T=!T2P!%MSG * %NEW_TEXT%
You can also do the expansion the other way round, i.e.
set NEW_TEXT=!MY_TEXT:T=%T2P%!
You could use 'sed' like this:
echo "cat rat mat fat" | sed 's/t/p/g' # outputs "cap rap map fap"