@ECHO OFF
REM ########################################################################
REM # A Windows XP cmd.com script to batch convert mp4 files to mp3. #
REM # #
REM # Created by DieselDragon on 10th Nov 2010CE, derived from a copyright #
REM # (C) 2008CE work of Andrew Boden
REM # http://wiki.videolan.org/How_to_Batch_Encode #
REM # Changed, cited and redistributed under the GNU GPL as detailed below #
REM # #
REM # This program is free software: you can redistribute it and/or modify #
REM # it under the terms of the GNU General Public License as published by #
REM # the Free Software Foundation, either version 3 of the License, or #
REM # (at your option) any later version. #
REM # #
REM # This program is distributed in the hope that it will be useful, #
REM # but WITHOUT ANY WARRANTY; without even the implied warranty of #
REM # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
REM # GNU General Public License for more details. #
REM # #
REM # You should have received a copy of the GNU General Public License #
REM # along with this program. If not, see
REM # #
REM # Version 1.10 (Derivative – DieselDragon, November 2010CE) #
REM # Uses VideoLAN VLC 1.1.4 (www.videolan.org) #
REM # Gracefully handles commas and apostrophes in file names. #
REM # Not aware of any other characters needing graceful handling. #
REM # 128kbps encoding with 44100 sampling. #
REM ########################################################################
FOR /R %%G IN (*.mp4) DO (CALL :SUB_VLC “%%G”)
FOR /R %%G IN (*.mp4.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%
ECHO Transcoding %1
REM Here’s where the actual transcoding/conversion happens. The next line
REM fires off a command to VLC.exe with the relevant arguments:
CALL “C:\Program Files\VideoLAN\VLC\vlc” -I dummy -v %1 :sout=#transcode{vcodec=none,acodec=mp3,ab=128,channels=2,samplerate=44100}:standard{access=”file”,mux=dummy,dst=”%_commanm%.mp3″} vlc://quit
REM Having no SLEEP-esque command, we have to trick DOS/Windows into pausing
REM for a bit between encode ops – To give the host OS a chance to do what it
REM needs to – Via clever use of the PING utility:
REM (Thanks to http://www.computing.net/answers/programming/dos-command-for-wait-5-seconds/11192.html for the tip! :-)
PING -n 1 -w 5000 1.1.1.1 > NUL
GOTO :eof
:SUB_RENAME
SET _origfnm=%1
SET _endbit=%_origfnm:*.mp4=%
CALL SET _newfilenm=%%_origfnm:.mp4%_endbit%=.mp3%%
SET _newfilenm=%_newfilenm:_COMMA_=,%
COPY %1 %_newfilenm%
DEL %1
GOTO :eof
:eof
REM My own little addition to prevent the batch window from “vanishing” without
REM trace at the end of execution, as if a critical error had occurred.
PAUSE