Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Name: tonysathre
The file name has a fixed pattern before the underscore so you can use that. As for the latest version, you can use the time stamp. Forget about using batch to parse HTML. Use more useful tools like perl/python that makes your job easier

Yeah, the <'s and the >'s make parsing in batch near impossible. If you want to stay with native scripting languages in Windows, you'll have to use JScript or VBScript. If you just want the easiest parsing language, go with Perl. After all, Perl grew out of the text parsing language, AWK.

This is hardwired to get the latest avg75amwt*.exe ; you can tailor the FIND line to suit.
::==
:: get AVG.bat :: gets latest avg75amwt*.exe@echo off
setLocal EnableDelayedExpansionfor %%F in (q r s t u v w x y z) do if exist %%F del %%F
wget http://download.grisoft.cz/filedir/...
find "avg75amwt" < index.html > q
for /f "tokens=1-4 delims==" %%a in (q) do (
echo %%d >> r
)for /f "tokens=2-3 delims=>" %%a in (r) do (
echo %%a %%b >> s
)for /f "tokens=1-2 delims=<" %%a in (s) do (
echo %%a %%b >> t
)for /f "tokens=1-2 delims=^/" %%a in (t) do (
echo %%a %%b >> u
)for /f "tokens=1,3 delims= " %%a in (u) do (
echo %%b %%a >> v
)for /f "tokens=1-4 delims=- " %%a in (v) do (
echo %%c %%b %%a %%d >> w
)for /f "tokens=* delims= " %%a in (w) do (
set str=%%aset str=!str:Jan=01!
set str=!str:Feb=02!
set str=!str:Mar=03!
set str=!str:Apr=04!
set str=!str:May=05!
set str=!str:Jun=06!
set str=!str:Jul=07!
set str=!str:Aug=08!
set str=!str:Sep=09!
set str=!str:Oct=10!
set str=!str:Nov=11!
set str=!str:Dec=12!echo !str! >> x
)sort < x > y
for /f "tokens=4 delims= " %%a in (y) do (
set AVG=%%a
)echo wget http://download.grisoft.cz/filedir/...
for %%F in (q r s t u v w x y z) do if exist %%F del %%F
::==Yes, boys and girls, I know it's a kludge.
=====================================
If at first you don't succeed, you're about average.M2

well... almost
Add the following line to clear out old index files BEFORE the first wget:
if exist index*.* del index*.*
=====================================
If at first you don't succeed, you're about average.M2

For any other techs out there, here's the final script:
::==getAVG.bat
:: Gets the latest version of AVG Free Edition
::
:: Requirements: wget.exe Win32
:: Windows NT/2000/XP
::
::@echo off
:start
setLocal EnableDelayedExpansion:: Set version
set ver=75:: Get old version
for /f "tokens=*" %%i in ('dir /b ^| findstr /i "avg75"') do (
set old_ver=%%i
)for %%f in (q r s t u v w x y z) do (
if exist %%f del %%f
)if exist index*.* (
del index*.*
)wget http://download.grisoft.cz/filedir/...
find "avg%ver%free" < index.html > q
for /f "tokens=1-4 delims==" %%a in (q) do (
echo %%d >> r
)for /f "tokens=2-3 delims=>" %%a in (r) do (
echo %%a %%b >> s
)for /f "tokens=1-2 delims=<" %%a in (s) do (
echo %%a %%b >> t
)for /f "tokens=1-2 delims=^/" %%a in (t) do (
echo %%a %%b >> u
)for /f "tokens=1,3 delims= " %%a in (u) do (
echo %%b %%a >> v
)for /f "tokens=1-4 delims=- " %%a in (v) do (
echo %%c %%b %%a %%d >> w
)for /f "tokens=* delims= " %%a in (w) do (
set str=%%aset str=!str:Jan=01!
set str=!str:Feb=02!
set str=!str:Mar=03!
set str=!str:Apr=04!
set str=!str:May=05!
set str=!str:Jun=06!
set str=!str:Jul=07!
set str=!str:Aug=08!
set str=!str:Sep=09!
set str=!str:Oct=10!
set str=!str:Nov=11!
set str=!str:Dec=12!echo !str! >> x
)sort < x > y
for /f "tokens=4 delims= " %%a in (y) do (
set AVG=%%a
)if exist !AVG! (
goto :cleanup
) else (
goto :wget
):wget
wget http://download.grisoft.cz/filedir/...
if not exist !AVG! goto start:cleanup
for %%f in (q r s t u v w x y z) do if exist %%f del %%f
del /f /q index*.*:: Delete old version
del /f /q %old_ver%
"Computer security." — Oxymoron

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |