Search code examples
batch-filevlc

How to get on video Shell folder with command line for any windows system?


I'm making a new batch file to convert any *.mp4 files to *.mp3 files with VLC in command line, but i want to improve it to choose the Input folder on Videos for any windows system !

My question is : How to get on videos folder with command line for any windows system?

Here is my code : MP4-MP3_Converter.bat

@echo off
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
)

Set "MP4Folder=C:\MP4Folder"
Set "MP3Folder=C:\MP3Folder"
If not exist "%MP3Folder%" MD "%MP3Folder%"
CD /D "%MP4Folder%"
for %%a in (*.mp4) do (
    Cls
    echo(
    echo           Please wait a while ... The Conversion is in progress ...
    echo   Conversion of "%%~na.mp4" to "%%~na.mp3"
    "%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

Solution

  • Not sure how consistent this is across different Windows versions, but I suspect you can use "%userprofile%\videos".

    But what is so special about that location? You are making a big assumption that all videos of interest are in that location. For example, I never use that folder, yet I have loads of videos on my hard drive.