maytham-ɯɐɥıλɐɯ has the key component of a simple solution - FOR / F. But this solution has many complications that seem to be unrelated to the issue.
The answer may be as simple as:
@echo off set "ip=170.150.120.10" for /f "tokens=1-3 delims=." %%A in ("%ip%") do set "new_ip=%%A.%%B.%%C.1" echo new ip=%new_ip%
Note You included spaces before and after = in the SET statement in your question. This is a bad idea, since all spaces are significant. You have a variable name that ends with a space and a value that starts with a space. I removed unnecessary spaces from the answer
In addition, I enclosed the appointment in quotation marks. All characters after the last quote are ignored if the first quote is before the variable name. This protects against inadvertent end gaps in your value.
EDIT 2017-09-04
An even simpler method is to treat the address as a file name, so the last node becomes the extension. Use a simple FOR and the ~n modifier to get the base name (first 3 nodes), and then add your own extension (last node).
for %%A in (%ip%) do set "new_ip=%%~nA.1"
source share