Hello guys i ran the code to remove spaces for the ipconfig command and i met this problem whereby theres an invisible rectangle after .134..i am wondering how to solve this..thanks in advance:)
Result:
IPAddress............:192.168.199.134[]-< weird rectangle
Code:
SETLOCAL EnableDelayedExpansion
IPCONFIG | findstr /C:"IP Address" >> IPCONFIG.txt
for /f "delims=" %%a in (IPCONFIG.txt) do (
set line=%%a
set line=!line: =!
!
echo !line! >> IPCONFIGNS.txt
)
FOR /f "tokens=2 delims=:" %%a IN (IPCONFIGNS.txt) DO (
SET IP=%%a
)
Remove weird rectangle at end of line
Moderator: DosItHelp
Re: Remove weird rectangle at end of line
Normally a line ends with 0D 0A (Carriage Return + Line Feed).
The bug of IPCONFIG is that the lines end with 0D 0D 0A. So you have one unintended CR character (some editors show it as rectangle).
If you loop over the output you can normalize it by %%~nxa instead of %%a.
Much shorter and without additional files:
Regards
aGerman
The bug of IPCONFIG is that the lines end with 0D 0D 0A. So you have one unintended CR character (some editors show it as rectangle).
If you loop over the output you can normalize it by %%~nxa instead of %%a.
Much shorter and without additional files:
Code: Select all
setlocal EnableDelayedExpansion
for /f "delims=: tokens=2" %%a in ('ipconfig^|findstr /c:"IP"') do (set "IP=%%~nxa" &set "IP=!IP: =!")
Regards
aGerman