@echo off
setlocal EnableDelayedExpansion

set a1=%APPDATA%
set b1=com.mar.goldminer
set b2=Local Store
set b3=#SharedObjects
set b4=main.swf
set f1=dat
set f2=777
set f3=.sav

set "p0=%a1%\%b1%\%b2%\%b3%\%b4%"
set "t1=%f1%%f2%%f3%"
set "outFile=%~dp0%t1%"

set "max=0"

for %%F in ("%p0%\*.sol") do (
    set "filename=%%~nF"
    set "score=!filename:~3!"
    for /f "delims=0123456789" %%C in ("!score!") do set "score="
    if defined score (
        set /a "num=!score!"
        if !num! gtr !max! set "max=!num!"
    )
)

> "!outFile!" echo !max!
