[Batch] How to convert MP4 to MP3 files using VLC in command line


By: Hackoo
February 7, 2018

This batch file can convert any (*.mp4) files in a folder and its subfolders to (*.mp3) files using VLC in command line.
For any update check this link : https://pastebin.com/tHsKw15V

@echo off & Setlocal EnableDelayedExpansion 
Title Convert (*.mp4) to (*.mp3) with VLC by (c) Hackoo 2017 
mode con:cols=85 lines=5 & COLOR 0E 
Taskkill /IM "vlc.exe" /F >nul 2>&1 
echo. 
set "VLC_URL=http://www.videolan.org/vlc/download-windows.html" 
 
IF /I "%PROCESSOR_ARCHITECTURE%"=="x86" ( 
        Set "vlc=%ProgramFiles%\VideoLAN\VLC\vlc.exe" 
    ) else ( 
        Set "vlc=%ProgramFiles(x86)%\VideoLAN\VLC\vlc.exe" 

 
If Not Exist "%vlc%" ( 
    Cls & COLOR 0C 
    echo. 
    Echo       "The VLC program is not installed on your system" 
    TimeOut /T 5 /NoBreak>nul 
    Start "" %VLC_URL% 
    Exit 

 
Call :BrowseForFolder "Please choose the source folder" MP4Folder 
Set "MP3Folder=%~dp0MP3_Converted" 
If not exist "!MP3Folder!" MD "!MP3Folder!" 
CD /D "!MP4Folder!" 
for /f "delims=" %%a in ('Dir /A-D /S /B "*.mp4"') do ( 
   Cls 
   echo( 
   echo           Please wait a while ... The Conversion is in progress ... 
   echo             Conversion of "%%~na.mp4" to "%%~na.mp3" 
Call "%vlc%" -I dummy "%%a" --sout=#transcode{acodec=mp3,ab=128,vcodec=dummy}:std{access="file",mux="raw",dst="%MP3Folder%\%%~na.mp3"} vlc://quit 

Explorer "%MP3Folder%" & Exit 
::**************************************************************************** 
:BrowseForFolder 
set "psCommand="(new-object -COM 'Shell.Application')^ 
.BrowseForFolder(0,'%1',0,0).self.path"" 
for /f "usebackq delims=" %%I in (`powershell %psCommand%`) do set "%2=%%I" 
exit /b 
::****************************************************************************


Need more help?
Describe your Problem
Example: Hard Drive Not Detected on My PC

Ask Question