Tilepic scripts (2)

On request, the script to download and reconstruct TilePic images was modified for Windows users in a quick and dirty way. The requirements for using the script are installed versions of ImageMagick and wget for Windows. Place the following code in a text file, adjust the first two lines to point to the TilePic image and the locations of the installed programs, and change the extension of the filename to .bat to make it an executable script. The script will download all tiles with the highest resolution data. It can take several minutes to append all rows of tiles to make the final image, so be patient.

set file=http://www.reconbyfire.net/cgi-bin/getpic?photo/tilepic/image.tjp
set Path=C:\Program Files\ImageMagick-6.4.5-Q16\;C:\Program Files\Wget-1.11.4\;%Path%

cls
wget %file% -q -O - > info.txt

type info.txt | find /I "width" > width.txt
set /p width= < width.txt
set width=%width:width=%
set width=%width:~1%

type info.txt | find /I "height" > height.txt
set /p height= < height.txt
set height=%height:height=%
set height=%height:~1%

type info.txt | find /I "tilewidth" > tilewidth.txt
set /p tilewidth= < tilewidth.txt
set tilewidth=%tilewidth:tilewidth=%
set tilewidth=%tilewidth:~1%

type info.txt | find /I "tileheight" > tileheight.txt
set /p tileheight= < tileheight.txt
set tileheight=%tileheight:tileheight=%
set tileheight=%tileheight:~1%

type info.txt | find /I "numfiles" > numfiles.txt
set /p numfiles= < numfiles.txt
set numfiles=%numfiles:numfiles=%
set numfiles=%numfiles:~1%

set /a cols=%width%/%tilewidth%+1
set /a rows=%height%/%tileheight%+1
set /a first=%numfiles%-%cols%*%rows%
set i=%first%
set j=0
:loop
set /a i+=1
if %i% gtr %numfiles% goto :doneloop
set image=temp-%i%.jpg
wget %file%^&%i% -q -O %image% 
echo.%i% of %numfiles%
goto :loop
:doneloop
:loop2
set /a j+=1
if %j% gtr %rows% goto :doneloop2
set string=
set /a start=%first%+(%j%-1)*%cols%
set /a last=%first%+%j%*%cols%-1
set /a k=%start%-1
:loop3
set /a k+=1
if %k% gtr %last% goto :doneloop3
set string=%string% temp-%k%.jpg
goto :loop3
:doneloop3
montage %string% -tile %cols%x1 -mode concatenate row-%j%.jpg
goto loop2
:doneloop2
set string=
set j=0
:loop4
set /a j+=1
if %j% gtr %rows% goto :doneloop4
set string=%string% row-%j%.jpg
goto loop4
:doneloop4
convert %string% -append final.jpg
del width.txt
del height.txt
del tilewidth.txt
del tileheight.txt
del numfiles.txt
del info.txt
del temp-*.jpg
del row-*.jpg

The above script will download and reconstruct most TilePic images without problems. Some modifications may be required to handle exceptions, e.g. when all tiles have exactly the same dimensions, as this is just a first attempt to make a script running on a Windows machine.