@echo off
setlocal enabledelayedexpansion
set "pingCMD=ping -w 300 -n 1 127.0.0.1"
set "pct="
set "avg="
for /f "tokens=*" %%a in ('%pingCMD% ^| findstr /n /r /c:"([0-9]*%%" /c:"= [0-9]*ms" ') do (
if not defined pct (
for /f "tokens=2 delims=(%%" %%b in ("%%a") do set "pct=%%b"
) else ( for /f "tokens=7 delims=,= " %%b in ("%%a") do set "avg=%%b" )
)
echo %pct% %avg%
After searching in google images i've found that german ping output puts the percentage in a separate line. The same occurs in my spanish localized window, but not in english windows.
As the localization changes the lines, first for | findstr
finds the two lines with the data needed. Then, depending of the line, another for
is used to split the line where needed. In this moment i can not test it in another language but this should work with little changes.