batch to create a folder named IP address

April 21, 2011 at 03:26:56
Specs: Windows XP
Hi !
I'm looking for your tips...
I created a bat file that create a folder.
the name of the folder "copied" from the local IP Address of the PC.
this is the bat file:
----------------
ipconfig /all > tempIP.txt
for /F "tokens=2 delims=:" %%j in ('ipconfig ^| find "IP Address"') do set Host=%%j
set Host=%Host:~1%
ren tempIP.txt "%Host%.txt"
------------------
my problem is that I search for a spesific key "IP Address" that compatible for windows XP \ 2003 only.
but if I want to run this bat file in windows 2008 OS, the key must be changed to "IPv4 Address".

I dont want to have 2 bat files ,each for diffrent OS.
how can I create one file that compatible for diffrent OS?

Thanks


See More: batch to create a folder named IP address

Report •


#1
April 21, 2011 at 04:06:16
What about using findstr instead of find, that way you can specify multiple search strings:


findstr /c:"IP Address" /c:"IPv4 Address"


Report •

#2
April 21, 2011 at 04:53:39
Hi Judago,
thanks for your replay.
its sound like the answer that I searched for , but it doens't work for me...
I copying again the updated batch:

ipconfig /all > tempIP.txt
for /F "tokens=2 delims=:" %%j in ('ipconfig ^|findstr /c:"IP Address" /c:"IPv4 Address") do set Host=%%j
set Host=%Host:~1%
ren tempIP.txt "%Host%.txt"


Report •

#3
April 21, 2011 at 04:58:50
You're missing the closing single quote from the "in" part of your for loop.

Report •

Related Solutions

#4
April 21, 2011 at 05:12:20
works like magic !!!

thanks a lot Judago for your fast help :)


Report •

Ask Question