@ECHO OFF
:page1
set watitle=Alpha Channel Maker for CADchUP (or something else)
set watext=This utility reads all .tif and .bmp bitmaps from a folder and writes them transparent back with an alpha channel to a destination folder in .png format.~~This batch utility uses "Wizard's Apprentice" for GUI and "ImageMagick" for processing bitmaps.~~See http://wiki.cadchup.org for downloads, docs and licenses.
set wasig=Version 1.0, www.cadchup.org 
set waico=bitmap.ico
set wabmp=2m.bmp
start /w wizapp.exe NOBACK TB
if errorlevel 2 goto :cancel
:page2
set watext=Specify the folder containing source bitmaps (i.e. .tif and.bmp files).~~If filenames are similar with different extensions - like abc.tif and abc.bmp - only .bmp files are processed.
set wabat=%temp%\cuinfolder.bat
if exist %temp%\indir.txt set /p waoutput=<%temp%\indir.txt
start /w wizapp.exe FB DIR
if errorlevel 2 goto :cancel
if errorlevel 1 goto :page1
call %wabat%
set indir=%waoutput%
echo %indir%>%temp%\indir.txt
:page3
set watext=Specify the destination folder for generated.png files.~~Existing files are not overwritten, you may want to (re)move them now.
set wabat=%temp%\cuoutfolder.bat
if exist %temp%\outdir.txt set /p waoutput=<%temp%\outdir.txt
start /w wizapp.exe FB DIR
if errorlevel 2 goto :cancel
if errorlevel 1 goto :page2
call %wabat%
set outdir=%waoutput%
echo %outdir%>%temp%\outdir.txt
:page4
set watext=Specify the color that needs to become transparent.~~After pressing Finish ImageMagick will chew your bitmaps. This can take a while when it concerns large bitmaps, please be patient.
set wabat=%temp%\cucolor.bat
set wainput=White(#ffffff);Black(#000000)
set waoutnum=0
if exist %temp%\color.txt set /p waoutnum=<%temp%\color.txt
start /w wizapp.exe FINISH RB
if errorlevel 2 goto :cancel
if errorlevel 1 goto :page3
call %wabat%
set color=%waoutnum%
echo %color%>%temp%\color.txt
if %color% == 0 (set cindex=#000000) else (set cindex=#ffffff)
rem check dir existence 
if not exist %indir% goto :cancel
if not exist %outdir% goto :cancel
rem end of wizard - start of rest
rem dir %indir%\*.bmp /b /o:n>%temp%\cu_tmp.set
pause
for /R "%indir%" %%f in (*.bmp) do (.\convert.exe %indir%\%%~nf.bmp -transparent %cindex% %outdir%\%%~nf.png)
for /R "%indir%" %%f in (*.tif) do (.\convert.exe %indir%\%%~nf.tif -transparent %cindex% %outdir%\%%~nf.png)
echo "Finished making bitmaps transparant..."
pause
:cancel 
