@rd /S /Q converted
@md converted
@md converted\bglp
@md converted\d1namo

@echo Converting BGLP..
@cd source
@for /R %%G in (*.xml) do @call :CONVERT_BGLP "%%G" "%%~dpG" "%%~nG.log"
@cd ..


@echo Converting D1NAMO...
@cd d1namo
@for /R %%G in (*.csv) do @call :CONVERT_D1NAMO "%%G"  "%%~dpG" "%%~nG.imperfect.log"  "%%~nG.log" 
@del *.imperfect.log
@cd ..


@exit /B 0


:CONVERT_BGLP
@set Input_File=%1
@set Input_File=%Input_File:"=%
@set Output_File=%2..\converted\bglp\%3
@set Output_File=%Output_File:"=%
@echo Converting BGLP file: %Input_File%
@echo Producing log file: %Output_File%

@c:\programy\glucose3\compiled\console3 "..\config\convert to logs.ini"

@exit /B 0


:CONVERT_D1NAMO
@set D1NAMO_File=%1
@set D1NAMO_File=%D1NAMO_File:"=%

@ ..\scripts\rundll-ng ..\scripts\analysis.dll @convert_d1namo

@set D1NAMO_File=%2.\%3
@set D1NAMO_File=%D1NAMO_File:"=%

@set Converted_D1NAMO_File=%2..\converted\d1namo\%4
@set Converted_D1NAMO_File=%Converted_D1NAMO_File:"=%


@echo Converting D1NAMO file: %D1NAMO_File%
@echo Producing log file: %Converted_D1NAMO_File%


@c:\programy\glucose3\compiled\console3 "..\config\d1namo_log.ini"

@exit /B 0