|
Answer» Hi 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 ! So, i wonder How to get on videos folder with command line ? Thank you !
MP4-MP3_Converter.bat
Code: [Select]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%" & ExitThe correct way of retrieving special folder locations is via SHGetSpecialFolderLocation or the Vista and later 'IKnownFolder' INTERFACE. The former should be possible with VBScript, as it is one of the features of Scripting.FileSystemObject. (GetSpecialFolder()).
You COULD hack it to get it working in batch, as there are some registry keys that contain this information. You can find them in HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders. "My Video" would be the needed value.
There are a number of issues involved with using the key as noted here. It was effectively an early revision of how the special folders were stored dating back to the betas of Windows 95, but since it was documented and was being actively used by software, it was kept for release- and then more and more programs kept using it so we STILL have it all the way up through Win10. The limitations might not really apply for what you want to do though.
Speaking of the registry, VLC saves it's install location in the registry, so you could retrieve that information that way too. It can be found in HKEY_LOCAL_MACHINE\SOFTWARE\VideoLAN\VLC (may need to also use the Wow6432Node to drill into the 32-bit registry)
Quote from: BC_Programmer on July 07, 2017, 08:01:23 PM You COULD hack it to get it working in batch, as there are some registry keys that contain this information. You can find them in HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders. "My Video" would be the needed value.
Thank you BC_Programmer, you put me on the right direction
Code: [Select]echo off Set "ShellFolderKey=HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" Set "MyKey=My Video" For /f "tokens=4,* Delims= " %%A in ('Reg Query "%ShellFolderKey%" /v "%MyKey%" ^| Findstr /C:"%MyKey%"') Do ( echo "%%A" ) pause
|