@echo off
mode 80,30

set BIKfilename=bink.exe
set BRDfilename=radutil.dll
set BMKfilename=binkmake.dll

set WD_EBink=WD_ErrorBink.txt

if NOT exist %BIKfilename% (
echo.
echo [%BIKfilename%] is not located in this folder...
echo.
goto :End
)

if NOT exist %BRDfilename% (
echo.
echo [%BRDfilename%] is not located in this folder...
echo.
goto :End
)

if NOT exist %BMKfilename% (
echo.
echo [%BMKfilename%] is not located in this folder...
echo.
goto :End
)

:choice
cls
echo.
echo *******************************************************************************
echo *                                                                             *
echo *                 Watch Dogs    ~    Rebuild BIK files to 50%%                 *
echo *                                                                             *
echo *                                                                             *
echo *                                                                             *
echo *       Press [1] to start the rebuilding procedure...                        *
echo *       Press [2] to start the renaming procedure...                          *
echo *                                                                             *
echo *                                                                             *
echo *       Remark:                                                               *
echo *       You must download RADtools and copy the appropriate files             *
echo *       to the current folder!                                                *
echo *                                                                             *
echo *       When finished, check the error log.                                   *
echo *       If everything is ok, run the renaming procedure to restore            *
echo *       the files back to their original name!                                *
echo *                                                                             *
echo *                                                                             *
echo *  Current Folder:                                                            *
echo *  [%~dp0]
echo *                                                                             *
echo *                                                                             *
echo *******************************************************************************
echo.
set /p userinp=Type a number (0,1-2): 
set userinp=%userinp:~0,1%
echo.
echo.
if "%userinp%"=="0" (
echo Quiting...
goto :END
)
if "%userinp%"=="1" goto Start
if "%userinp%"=="2" goto Brename
echo invalid choice
goto choice


:Start
%~d0
cd %~dp0

type nul>%WD_EBink%

setlocal EnableDelayedExpansion
set Count=0

for /F "delims=~" %%i in ('dir *. /b /A:-D') do (
set /a Count=!Count!+1
echo [!Count!]:  %%i

Bink %%i %%i_NEW.bik /D50 /M3.0 /L10 /B16 /C2 /^#

if not !ErrorLevel! equ 0 (
    echo Bink error: %%i >> %WD_EBink%
) ELSE (
    del %%i )

)
goto choice


:Brename
%~d0
cd %~dp0

setlocal EnableDelayedExpansion
set Count=0

for /F "delims=~" %%i in ('dir *.bik /b') do (
set name=%%~ni
set name=!name:~0,-4!
echo [!Count!]:  %%~ni    ~    [!name!]
ren %%i !name!

)
goto choice


:END
echo.
pause