@echo off
REM Options (use Quotes in Path with spaces e.g. C:\"Program Files"\...)
SET lameoptions=-b 32 -m j -V 4 -B 128 --resample 44.1
SET path_mpg123=C:\"Program Files"\mgg123\mpg123.exe
SET path_lame=C:\"Program Files"\Lame\lame.exe

REM You need:
REM mpg123:   http://www.mpg123.de/
REM Lame:     http://lame.sourceforge.net/

REM Filename
SET fullfilename=%~1
REM decode with mpg123
START /MIN /WAIT %path_mpg123% -w "%fullfilename%.wav" "%fullfilename%"
IF %ERRORLEVEL% == 0 (
	REM encode with Lame
	START /MIN /WAIT %path_lame% %lameoptions% "%fullfilename%.wav" "%fullfilename%"
	REM delete temporary file
	IF %ERRORLEVEL% == 0 (
		DEL /Q "%fullfilename%.wav"
	)
)
