Re: Double quotes in For loop input [SOLVED]
Posted: 30 Jun 2012 04:26
Here is a version that doesn't use SED and maybe the file.htm it generates would be easier to parse in batch for you. This strips out all of the bogus IP information that the site includes.
Code: Select all
@echo off
setlocal enabledelayedexpansion
call :sar filein.htm fileina.htm "<div style=.display:none.>[0-9]*<\/div>" ""
call :sar fileina.htm file.htm "<span style=.display:none.>[0-9]*<\/span>" ""
htmstrip /-table /border=b file.htm
find "TP" <file.out |find /v ">" >file.txt
for /f "delims=" %%a in (file.txt) do (
set var=%%a
set var=!var:~11!
for /f "tokens=1-6" %%b in ("!var!") do (
if /i "%%f%%g"=="High+KA" echo %%b,%%c,%%d,%%e,%%f, %%g
)
)
pause
goto :EOF
:sar
::Search and replace
@echo off
if "%~3"=="" (
echo.Search and replace
echo Syntax:
echo %0 "filein.txt" "fileout.ext" "regex" "replace_text" [first]
echo.
echo. if [first] is present only the first occurrence is changed
goto :EOF
)
if "%~5"=="" (set global=true) else (set global=false)
set s=regex.replace(wscript.stdin.readall,"%~4")
>_.vbs echo set regex=new regexp
>>_.vbs echo regex.global=%global%
>>_.vbs echo regEx.IgnoreCase=True
>>_.vbs echo regex.pattern="%~3"
>>_.vbs echo wscript.stdOut.write %s%
cscript /nologo _.vbs <"%~1" >"%~2"
del _.vbs