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

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Hackoo
Posts: 103
Joined: 15 Apr 2014 17:59

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

#1 Post by Hackoo » 07 Jul 2017 20:00

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 ? :roll:
Thank you !
Here is my code : MP4-MP3_Converter.bat

Code: Select all

@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

PaperTronics
Posts: 118
Joined: 02 Apr 2017 06:11

Re: How to get on videos folder with command line for any windows system ?

#2 Post by PaperTronics » 07 Jul 2017 21:56

Hackoo wrote: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 ?


Do you mean you want the user to choose the folder in where the converted videos will be stored? If so, you can just get user input for the folder that they want to store the converted videos. If there is no input then you can use the default path which can be either the desktop or any other directory.

Code: Select all

@Echo off
Setlocal EnableDelayedExpansion
set /p store="Enter the full path of the folder you want to store the converted files in :
 


Also, you should ask the user where VLC is installed in their computer. As all computers don't have VLC installed in the Program Files directory. Even I have VLC installed in my D:/ directory. So if I were to use this program, it would just say that VLC isn't installed on my computer. I think you should make an option for the user, that if they have it installed in the Program Files or do they have another path for VLC.


PaperTronics

JuanMa777
Posts: 17
Joined: 06 Nov 2016 13:15
Location: La Plata, ¡Argentina!

Re: How to get on videos folder with command line for any windows system ?

#3 Post by JuanMa777 » 08 Jul 2017 03:17

Hi,
I haven't MS Windows Seven, but I have a machine with XP and a virtual system with Vista. In the last two doesn't exist "Videos" folder. Maybe started to be implemented in 7. In 8 and 8.1 it is likely to be on the same path as MS Windows 10, that is where I write to you.
I think that you can do this, but verify 7 and 8:

Code: Select all

%homedrive%
cd "%userprofile%\videos"


I hope this is the right thing to do.
Sorry for my English, today I woke up 4 a.m. :? .

Hackoo
Posts: 103
Joined: 15 Apr 2014 17:59

Re: How to get on videos folder with command line for any windows system ?

#4 Post by Hackoo » 09 Jul 2017 05:36

Thank you all for your reply !
So we could hack it to get it working in batch, as there are some registry keys that contain this information. we can find them in

Code: Select all

HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders 
"My Video" would be the needed value.
So with this batch file we can do it :

Code: Select all

@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 (
   Set "MyVideoShellFolder=%%A"
   )
       echo "%MyVideoShellFolder%"
pause

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: How to get on videos folder with command line for any windows system ?

#5 Post by aGerman » 09 Jul 2017 06:00

Doesn't it point to the same folder as "%userprofile%\Videos" that JuanMa777 proposed?
Note that "entries that appear in user User Shell Folders take precedence over those in Shell Folders".

Steffen

JuanMa777
Posts: 17
Joined: 06 Nov 2016 13:15
Location: La Plata, ¡Argentina!

Re: How to get on videos folder with command line for any windows system ?

#6 Post by JuanMa777 » 09 Jul 2017 08:54

Hi,
Note Steffen that perhaps Hackoo wanted to say the folder as a variable.

I correct my words:
In Vista exist Videos folder, sorry: :roll: .
In my XP Home My Videos registry key is empty, perhaps for Home edition.

Now remember that I have the same problem with "startup" folder.
One solution is yours, other is call a vbscript from batch, and other is a hybrid vbs-batch script. Your solution is right, but no universal, because if in the path exists non ascii character don't work, because then the variable is not recognized... I should have some vbscript-batch hybrid scripts, or perhaps exist another solution to this.

Keep in mind that say you Steffen respect of "entries that appear in user User Shell Folders take precedence over those in Shell Folders". He must know more.

P.D.: You can put

Code: Select all

findstr %homedrive%"%MyKey%"
, because in some rare cases the c: drive is not the system drive, :).

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: How to get on videos folder with command line for any windows system ?

#7 Post by aGerman » 09 Jul 2017 09:51

JuanMa777 wrote:He must know more.

I linked my source :wink:

Steffen

JuanMa777
Posts: 17
Joined: 06 Nov 2016 13:15
Location: La Plata, ¡Argentina!

Re: How to get on videos folder with command line for any windows system ?

#8 Post by JuanMa777 » 09 Jul 2017 20:19

Hi Steffen,
I meant: He probably knows more. It was a compliment, you have 2700 post!
My English is not good, and sometimes I use Google translate: :lol:
I'm learning German, I hope to be better with your lenguaje.
Viele Grüße!

Post Reply