-2

I have a batch command where a user enters an IP address and then I need to modify the last octet based on the second option the user enters. Is there a way to delimit an IP address based on the period? I have only seen ways to use the standard options.

My apologies, I forgot to include what I've got, I would like to find a way to break %a into four different strings.

echo. Enter IP address of the CSR on the site.
echo. Example: 11.152.34.82
set /p a="IP Address: "
pause
cls
echo. select the technology you are trying to restore
echo. 1: AWS
echo. 2: PCS
echo. 3: LTE 1
echo. 4: LTE 2
set /p w="Enter number: "
if "%w%"=="1" goto AWS 
if "%w%"=="2" goto PCS
if "%w%"=="3" goto LTE1
if "%w%"=="4" goto LTE2
echo. Not found
goto commonexit
Cœur
  • 37,241
  • 25
  • 195
  • 267
Chris
  • 1
  • 1
  • 2
    Well, Chris, if you want more people here to help, you should show us *in details* what you tried. Most of us don't want to write code for free... Please read http://stackoverflow.com/help/how-to-ask before asking your next question. – J. Chomel Sep 27 '16 at 12:19
  • Possible duplicate of [Split string in batch file](http://stackoverflow.com/questions/29739131/split-string-in-batch-file) – geisterfurz007 Sep 27 '16 at 12:42
  • You appear to be speaking of two different processes, a user process and then your process. What are you working with an input file of some sort? and if so is the input verified as a valid IPv4 address? – Compo Sep 27 '16 at 12:43

1 Answers1

2

This command splits based on the period.

for /f "tokens=1,2,3,4 delims=." %%a  in ("192.168.1.1") do echo Split into: %%a %%b %%c %%d
FloatingKiwi
  • 4,408
  • 1
  • 17
  • 41