@echo off
mode 80,60

set WD_EList2=WD_ErrorList2.txt
type nul> %WD_EList2%

REM ********************************************
REM *** Convert to CRN              # Proc_DDS #
REM ********************************************
rem *** %1= Filename
rem *** %2= Fourcc code
rem *** %3= type of conversion

rem *** you can not use "." on the crunch commandline...
set Tfile1="%~dpnx1"
set Tfile2="%~dpn1".crn

rem echo %1   ~  [%2]   ~  %3   ~    [%Tfile1%]  ~ [%Tfile2%]

echo.
echo Treating file: [%~nx1]
echo.

if %3==CRN (

    rem **** to CRN: A8R8G8B8 => -DXT5A
    crunch_x64 /outsamedir -file "%~dpnx1" -%2 -quality 128

    if exist "%~dpn1".%3 ( del "%~dpnx1" )

)

if %3==DDS (

    rem **** to DDS: DXT5A => -A8R8G8B8
    crunch_x64 /outsamedir -file "%~dpn1.crn" -%2

    if exist "%~dpn1".%3 ( del "%~dpn1.crn" )
)

if not exist "%~dpn1".%3 ( echo Compression Fault: "%~dpnx1" >> %WD_EList2% )

rem *** End of :Proc_DDS procedure...

exit