Obtain IP and the remove last octet

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Qazxswe
Posts: 1
Joined: 02 Jun 2015 02:14

Obtain IP and the remove last octet

#1 Post by Qazxswe » 02 Jun 2015 02:34

I need to copy 3 *.xmls to a networked device at 850 sites each with the own IP schema.

The batch file needs to run, obtain the PC IP address and change last octet to .150 and then map the drive and copy the files.

I am obtaining the IP like this:

Code: Select all

for /F "tokens=2 delims=:" %%i in ('"ipconfig | findstr IP | findstr 192."') do SET LOCAL_IP=%%i


How can I then remove the last octet from the %LOCAL_IP% to map a drive to \\xxx.xxx.xxx.150\c$\directory ?

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Obtain IP and the remove last octet

#2 Post by foxidrive » 02 Jun 2015 20:02

Look at modifiers for for /?

This is not a clearly defined way of using the modifier but it does what you ask:

Code: Select all

...do SET LOCAL_IP=%%~ni

Post Reply