@echo off

:choice
cls
echo.
echo *******************************************************************************
echo *                                                                             *
echo *                 Watch Dogs    ~    Create DDS =^> XBT Files                  *
echo *                                                                             *
echo *       Recreates all XBT files based on its resp. DDS and HDR files          *
echo *                                                                             *
echo *                                                                             *
echo *       Press [1] to start the building procedure...                          *
echo *                                                                             *
echo *                                                                             *
echo *  Current Folder:                                                            *
echo *  [%~dp0]
echo *                                                                             *
echo *                                                                             *
echo *******************************************************************************
echo.
set /p userinp=Type a number (0,1): 
set userinp=%userinp:~0,1%
echo.
echo.
if "%userinp%"=="0" (
echo Quiting...
goto :END
)
if "%userinp%"=="1" goto Start
echo invalid choice
goto choice


:Start
set WD_FList=WD_FListGraph.txt
set WD_Alist=WD_AlphaList.txt
set WD_FinalList=WD_FinalList.txt
set WD_EList3=WD_ErrorList3.txt

type nul > %WD_EList3%

dir *.dds /b>WD_FListGraph.txt 2>nul

%~d0
cd %~dp0

setlocal EnableDelayedExpansion
Set Count=0
for /F "delims=~" %%i in (%WD_FList%) do (
set /a count=!count!+1
echo !count!

copy /b "%%~ni".hdr+%%i "%%~ni".xbt >nul 2>nul

if not !ErrorLevel! equ 0 ( 
    echo Copy Header error: %%i >> %WD_EList3%
) ELSE (
    del "%%i" "%%~ni.hdr"
)

)


:END
 
del %WD_FList% >nul 2>nul

echo.
pause