To replace a substring with another string use the string substitution feature.
@echo off set str=This message needs changed. echo %str% set str=%str:needs=has% echo %str%
The key thing to note about the above program is, the example replaces the word ‘needs’ with the string ‘has’ via the statement %str:needs = has%
The above command produces the following output.
This message needs changed. This message has changed.