@ECHO OFF
SETLOCAL EnableDelayedExpansion

SET CODEWARRIOR_LINKER="C:\Program Files (x86)\Metrowerks\CodeWarrior\PS2_Tools\Command_Line_Tools\mwldps2.exe"

ECHO Extracting debug symbols...

FOR /R . %%G IN (*.elf) DO (
  echo %%G
  %CODEWARRIOR_LINKER% -dis -show only,debug "%%G" > %%G.txt
  IF !ERRORLEVEL! NEQ 0 (
    ECHO Failed to extract debug symbols.
    EXIT /B 1
  )
)

ENDLOCAL