Friday, January 15, 2010

Convert multiple m4a files to mp3

Use VLC media player called from a batch file. Slight modification of a VLC wiki entry. It's GPLed?

Versions used
VLC media player - 0.9.2

rem @ECHO OFF
rem batch convert m4a files to mp3 (128kb/s encoding with 44100 sampling frequency)

FOR /R %%G IN (*.m4a) DO (CALL :SUB_VLC "%%G")
FOR /R %%G IN (*.m4a.mp*) DO (CALL :SUB_RENAME "%%G")
GOTO :eof

:SUB_VLC
SET _firstbit=%1
SET _qt="
CALL SET _newnm=%%_firstbit:%_qt%=%%
SET _commanm=%_newnm:,=_COMMA_%
REM echo %_commanm%
CALL "C:\Program Files\VideoLAN\VLC\vlc" -I dummy -vvv %1 --sout=#transcode{acodec="mp3",ab="128","channels=2",samplerate="44100"}:standard{access="file",mux="raw",dst="%_commanm%.mp3"} vlc://quit
GOTO :eof

:SUB_RENAME
SET _origfnm=%1
SET _endbit=%_origfnm:*.m4a=%
CALL SET _newfilenm=%%_origfnm:.m4a%_endbit%=.mp3%%
SET _newfilenm=%_newfilenm:_COMMA_=,%
COPY %1 %_newfilenm%
DEL %1
GOTO :eof

:eof

2 comments:

  1. Great, just had to adjust the path to vlc, i.e. Program Files (x86) in my case. Thanks!

    ReplyDelete
  2. Great file, but a few problems with file names like "D'yer Mak'er.m4a". Nothing that can't be sorted manually :)

    ReplyDelete