Youtube-dl cannot read various set on batch script - batch-file

I created an batch-script that positioned with youtube-dl and ffmpeg. I set several set to put URL and Video/Audio ID. Here my script that I simplified
#echo off
cd /d %root%\YT
color 0a
title Youtube Downloader
setlocal enableDelayedExpansion
set q=^"
color 0a
:submenu
echo Please enter URL.
set /p f1="URL: "
echo Checking ID...
youtube-dl -F %f1%
ping localhost -n 2 >nul
goto menu
:menu
echo.
echo Script created by UrbaseR
echo ___________________________________________________________
echo.
echo MENU
echo ___________________________________________________________
echo OS Windows - %ComputerName%
echo.
echo M E N U
echo Press 1 to Download Best version
echo Press 2 to Download Custom version + convert
echo Press 3 to Exit
set /p you=">"
if %you%==1 goto 1
if %you%==2 goto 2
if %you%==3 goto 3
cls
echo *********************************
echo Sorry invalid number!
echo *********************************
ping localhost -n 2 >nul
goto menu
:1
echo Downloading...
youtube-dl -f best %f1%
echo.
echo Done
ping localhost -n 2 >nul
cls
goto submenu
:2
set /p id1="Insert Video ID: "
set /p id2="Insert Audio ID: "
echo Downloading Video..
youtube-dl -f %id1% -ciw -o "vid.%(ext)s" -v --write-sub %f1%
echo.
echo Video Done
ping localhost -n 2 >nul
echo Downloading Audio..
youtube-dl -f %id2% -ciw -o "aud.%(ext)s" -v %f1%
echo.
echo Audio Done
ping localhost -n 2 >nul
echo Converting Video
ffmpeg -i "vid.%(ext)s" -i "aud.%(ext)s" -c:v copy -c:a aac -strict experimental "input.mkv"
echo Converting Done
ping localhost -n 4 >nul
cls
goto submenu
:3
exit
First and third option execute successfully. Second option will appear the message like this:
Usage: youtube-dl [OPTIONS] URL [URL...]
youtube-dl: error: You must provide at least one URL.
Type youtube-dl --help to see a list of all options.
Note: Since I stuck on first and second stage of youtube-dl, ffmpeg may not work (I have not tested it yet).
Can you help me?

After re-fix the script is pretty much done.
#echo off
cd /d %root%\YT
color 0a
title Youtube Downloader
setlocal enableDelayedExpansion
set q=^"
color 0a
:submenu
echo Please enter URL.
set /p f1="URL: "
cls
echo Checking ID...
youtube-dl -F %f1%
ping localhost -n 2 >nul
goto menu
:menu
echo.
echo.
echo Script created by UrbaseR
echo ___________________________________________________________
echo.
echo MENU
echo ___________________________________________________________
echo OS Windows - %ComputerName%
echo.
echo M E N U
echo Press 1 to Download Best version (default ver)
echo Press 2 to Download Custom version + Convert
echo Press 3 to Exit
echo.
echo URL: %f1%
set /p you=">"
if %you%==1 goto 1
if %you%==2 goto 2
if %you%==3 goto 3
cls
echo *********************************
echo Sorry invalid number!
echo *********************************
ping localhost -n 2 >nul
goto menu
:1
echo Downloading...
youtube-dl -f best %f1%
echo.
echo Done
ping localhost -n 2 >nul
cls
goto submenu
:2
set /p id1="Insert Video ID: "
set /p id2="Insert Audio ID: "
set ida="v.data"
set idb="a.data"
set "f2="
set "f3="
cls
echo Downloading Video..
youtube-dl -f %id1% -ciw --o %ida% -v --write-sub %f1%
echo.
echo Video Done
ping localhost -n 2 >nul
cls
echo Downloading Audio..
youtube-dl -f %id2% -ciw -o %idb% -v %f1%
echo.
echo Audio Done
ping localhost -n 2 >nul
cls
echo Note Default title is: input.mkv
echo.
set /p f2="Enter Video Title: "
if not defined f2 set "f2=input"
set /p f3="Format Video: "
if not defined f3 set "f3=mkv"
echo Converting Video..
ffmpeg -i %ida% -i %idb% -c:v copy -c:a aac -strict experimental "%f2%.%f3%"
echo Converting Done
del /q %ida%
del /q %idb%
ping localhost -n 4 >nul
cls
goto submenu
:3
exit
Feel free to use the script.
Note: Be sure to have youtube-dl.exe and ffmpeg.exe on same folder, video will also saved on same folder .

Related

FTP download progress bar in batch file

I wonder if there is a possibility the code below to enable a progress bar or percentage counter to check the progress of download, however alternativar not seen since the download is being executed by the FTP client.
Follows the code:
ECHO OFF
Color 17
Setlocal ENABLEDELAYEDEXPANSION
CLS
:MENU
ECHO.
ECHO ...............................................
ECHO . Selecione o numero desejado no menu abaixo .
ECHO ...............................................
ECHO.
ECHO 1 - Atualizar Frente/Retaguarda
ECHO 2 - Atualizar Rgourmet
ECHO 3 - Exit
ECHO.
SET /P M=Selecione 1, 2, ou 3 e pressione ENTER:
IF %M%==1 GOTO FRENTE
IF %M%==2 GOTO RGOURMET
IF %M%==3 GOTO SAIR
:FRENTE
# echo off
echo open 177.125.217.138>>frente.ftp
echo ****>>frente.ftp
echo ****>>frente.ftp
echo hash>>frente.ftp
echo cd atualizador>>frente.ftp
echo binary>>frente.ftp
echo get "libx12.dll">>frente.ftp
echo get "rjkmonitor.exe">>frente.ftp
echo get "rjkini.exe">>frente.ftp
echo quit>>frente.ftp
# echo off
echo off taskkill /F /IM rjkpdv.exe > NUL
echo off taskkill /F /IM libx12.dll > NUL
echo off taskkill /F /IM rjkretaguarda.exe > NUL
ftp -v -i -s:frente.ftp
if exist macro.txt (
rjkpdv.exe /a
rjkini.exe
) else (
del rjkretaguarda.exe
ren libx12.dll rjkretaguarda.exe
rjkretaguarda.exe /a
rjkini.exe
)
del frente.ftp
cls
GOTO MENU
:RGOURMET
# echo off
taskkill /F /IM rgourmet.exe
taskkill /F /IM rmt.exe
echo open 177.125.217.138>>rgourmet.ftp
echo ****>>rgourmet.ftp
echo ****>>rgourmet.ftp
echo hash>>rgourmet.ftp
echo cd atualizador>>rgourmet.ftp
echo binary>>rgourmet.ftp
echo get "rgourmet.exe">>rgourmet.ftp
echo get "rmt.exe">>rgourmet.ftp
echo get "rjkini.exe">>rgourmet.ftp
echo quit>>rgourmet.ftp
# echo off
ftp -v -i -s:rgourmet.ftp
rgourmet.exe /asgb
rjkini.exe
del rgourmet.ftp
cls
GOTO MENU
:SAIR
exit
The build-in Windows command-line FTP client (ftp.exe) cannot display progress of the transfer. All it can do, is what you already get with the hash command.
You have to use another FTP client to get percentage progress.
For example with WinSCP FTP client, you get the percentage progress by default.
winscp.com /command ^
"open ftp://rjk:password#177.125.217.138/" ^
"cd atualizador" ^
"get libx12.dll" ^
"get rjkmonitor.exe" ^
"get rjkini.exe" ^
"exit"
See a guide for converting Windows FTP script to WinSCP script.
(I'm the author of WinSCP)

Progress bar shows "echo is OFF" message

I'm trying to simulate a progress bar with ASCII characters, but any time my progress bar is more than 0% full, the message echo is OFF is displayed.
#echo off
setlocal EnableDelayedExpansion
color A
echo hacking main intelligence systems...
ping -n 2 127.0.0.1>nul
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo Loading... Please Wait
echo ---------------------------------------
echo :0 ]
echo ---------------------------------------
ping localhost -n 2 >nul
cls
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo Loading. Please Wait
echo ---------------------------------------
echo || :5 ]
echo ---------------------------------------
ping localhost -n 3 >nul
cls
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo Loading.. Please Wait
echo ---------------------------------------
echo |||| :15 ]
echo ---------------------------------------
ping localhost -n 2 >nul
The script continues on like that for a while, but this snippet is smaller and has the same issue.
What is causing the message to appear, and how can I correctly display the bar progressing?
Your actual question of why your echos aren't working is perfectly reasonable, and it's an extremely common error for beginners.
| is a symbol that takes the output of one command and uses it as the input of another command. In your case, you effectively have echo by itself, which will simply return the status of echo (in this case, echo is OFF).
In order to get around this, you can either use a different symbol, or you can open your code in a text editor and replace all instances of | with ^|.
^ is an escape character, which tells echo to interpret the symbol literally and print an actual | instead of using it to route command output.
#echo off
setlocal EnableDelayedExpansion
color A
echo hacking main intelligence systems...
ping -n 2 127.0.0.1>nul
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo Loading... Please Wait
echo ---------------------------------------
echo :0 ]
echo ---------------------------------------
ping localhost -n 2 >nul
cls
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo Loading. Please Wait
echo ---------------------------------------
echo ^|^| :5 ]
echo ---------------------------------------
ping localhost -n 3 >nul
cls
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo Loading.. Please Wait
echo ---------------------------------------
echo ^|^|^|^| :15 ]
echo ---------------------------------------
ping localhost -n 2 >nul

Tries in batch file not working on password entry

I need this file to give you 3 tries to enter a password and if not then shutdown or shut down any way 60 secs after the first failed attempt
please help
here is the batch file
#echo off
color 02
set /a %tries%== 4
set /p %password%== Mike.1587
taskkill /f /IM explorer.exe
shutdown -s -t 60000
goto MAIN-LAUNCH
:MAIN-LAUNCH
cls
if %tries%==0 goto DEATH-OVERRIDE-SHUTDOWN
title Locked by %username%
echo Enter Password Before Time Runs Out...
echo You have %tries% tries left
set /p password=
if %password%==Mike.1587 goto IF-TRUE
if not /p password=Mike.1587 goto NOT-TRUE
:NOT-TRUE
%tries% -1
echo Incorrect Password Try Again...
echo You have %tries% left
echo Press any key to try again. . .
pathping localhost -q 2 -p 3500> nul
goto MAIN-LAUNCH
:IF-TRUE
echo Correct!
start explorer.exe
shutdown -a
pathping localhost -q 2 -p 1000> nul
exit
DEATH-OVERRIDE-SHUTDOWN
shutdown.exe /s /t 00
exit
This should do what you want. A lot of your batch syntax is incorrect. I would recommend you go to a basic tutorial online before you start your next project.
#echo off
color 02
set /a tries=3
set /p P=Mike.1587
taskkill /f /IM explorer.exe
shutdown -s -t 60000
:: Start
:Attempt
cls
if "%tries%"=="0" goto Fail
title Locked by %username%
echo Enter Password Before Time Runs Out...
echo You have %tries% tries left
set /p "password=Password: "
if "%password%"=="%P%" goto Correct
:: Wrong Password
set /a tries-=1
echo Incorrect Password Try Again...
echo You have %tries% left
echo Press any key to try again. . .
pathping localhost -q 2 -p 3500> nul
goto Attempt
:Correct
shutdown -a
echo Correct!
start explorer.exe
pathping localhost -q 2 -p 1000> nul
exit
:Fail
shutdown.exe /s /t 00
exit

I Don't Know What Is Wrong With My Batch File

Help! I am making a batch file that you can make a list of people. Then when someone arrives you can type in their name and it will check if they're on the list. When the batch file checks if the person is on the list it does not work(I am using no capital letters and I am spelling it right) I need to figure out what is wrong with my batch file that is not working.
So the main problem is that when it checks for the person on the list it does not find it. Sorry, im not exactly sure how to phrase this. :)
Here is the code for my program.
#echo off
title Event Starter
echo Event Starter
set /p Eventname=Event Name:
cls
goto :Participants
:Participants
title Name Of Participants
set /p Name1=Name:
cls
set /p Name2=Name:
cls
set /p Name3=Name:
cls
set /p Name4=Name:
cls
set /p Name5=Name:
cls
set /p Name6=Name:
cls
set /p Name7=Name:
cls
set /p Name8=Name:
cls
pause
goto :checker
:checker
title Enter Person's Name
echo Enter Who Arrived To Check The Database
echo.
echo.
echo.
set /p check1=
goto :database
:database
title Checking Database For The Given Person
echo Checking Database For The Given Person
cls
echo 5 %
ping 1.1.1.1 -n 1 -w 5000 > nul
cls
echo 20 %
ping 1.1.1.1 -n 1 -w 5000 > nul
cls
echo 35 %
ping 1.1.1.1 -n 1 -w 5000 > nul
cls
echo 50 %
ping 1.1.1.1 -n 1 -w 5000 > nul
cls
echo 70 %
ping 1.1.1.1 -n 1 -w 5000 > nul
cls
echo 85 %
ping 1.1.1.1 -n 1 -w 5000 > nul
cls
echo 100 %
ping 1.1.1.1 -n 1 -w 5000 > nul
if %check1%==%Name1% goto :valid
if %check1%==%Name2% goto :valid
if %check1%==%Name3% goto :valid
if %check1%==%Name4% goto :valid
if %check1%==%Name5% goto :valid
if %check1%==%Name6% goto :valid
if %check1%==%Name7% goto :valid
if %check1%==%Name8% goto :valid
goto :invalid
:valid
title %check% Is On The List!
echo %check% Is On The List!
ping 1.1.1.1 -n 1 -w 5000 > nul
ping 1.1.1.1 -n 1 -w 5000 > nul
pause
goto :checker
:invalid
title %check% Is Not On The List!
echo %check% is Not On The List!
echo This Is Case-Sensative
ping 1.1.1.1 -n 1 -w 5000 > nul
ping 1.1.1.1 -n 1 -w 5000 > nul
goto :checker
To be honest, there is a lot of unnecessary lines there, so instead of pinpointing the error I have rewritten your script into a much cleaner version, which should hopefully solve the problems you were having as well! :)
#echo off
title Event Starter
setlocal enabledelayedexpansion
echo Event Starter
set /p Eventname=Event Name:
cls
title Name Of Participants
for /l %%a in (1,1,8) do (
set /p Name[%%a]=Name:
cls
)
:checker
title Enter Person's Name
echo Enter Who Arrived To Check The Database
echo.
echo.
echo.
set /p check1=
title Checking Database For The Given Person
echo Checking Database For The Given Person
cls
for %%b in (5,20,35,50,70,85,100) do (
echo %percent%%
ping 1.1.1.1 -n 6 > nul
cls
)
for /l %%a in (1,1,8) do (
if !check1!==!Name[%%a]! goto :valid
)
goto :invalid
:valid
title %check% Is On The List!
echo %check% Is On The List!
ping 1.1.1.1 -n 1 -w 10000 > nul
goto :checker
:invalid
title %check% Is Not On The List!
echo %check% is Not On The List!
echo This Is Case-Sensative
ping 1.1.1.1 -n 1 -w 10000 > nul
goto :checker
--EDIT--
Fixed the code. It should work now.
setlocal enabledelayedexpansion
:a
cls
set/p name=Name:
for /f "delims=" %%i in (File_path) do (
set name2=%%i
if /i !name! equ !name2! goto b
)
cls
echo They're not on the list...
pause
goto a
:b
cls
echo They're on the list...
pause
goto a
The script goes through the file checking if the user-defined name (name) is within it. If it is then it sends it to :b which reports back to you saying that they were on the list. You could modify this into a function by replacing the goto command with exit /b 2 for true (they were on the list) and exit /b 3 for false (they weren't).
The names should each be on a separate line, demonstrated below. Capitalization doesn't matter because of the /i switch on the if command.
Mark Finch
Julie Fernz
Tom Riddle...
I am not familiar with the syntax, but there is a difference between the way you input the initial names (e.g. set /p Name1=Name: ) and how you input the name to check (set /p check1= ). Is that significant?

How do I add a timer to a batch file?

I want to make a batch file that waits for a few minutes, then executes a command. How would I do this? Specifically, I want it to end another program in 3 minutes after opening the file.
Use timeout. That will let you wait for a number of seconds given in it's /t parameter. timeout /t 180 will sleep for 3 minutes (180 seconds).
TIMEOUT [/T] timeout [/NOBREAK]
Description:
This utility accepts a timeout parameter to wait for the specified
time period (in seconds) or until any key is pressed. It also
accepts a parameter to ignore the key press.
Parameter List:
/T timeout Specifies the number of seconds to wait.
Valid range is -1 to 99999 seconds.
/NOBREAK Ignore key presses and wait specified time.
/? Displays this help message.
NOTE: A timeout value of -1 means to wait indefinitely for a key press.
Examples:
TIMEOUT /?
TIMEOUT /T 10
TIMEOUT /T 300 /NOBREAK
TIMEOUT /T -1
Another method is to ping an invalid IP address for a certain amount of time:
PING 1.1.1.1 -n 1 -w 60000 >NUL
60000 = milliseconds
hi i love stockoverflow but sometimes the answers are too concise... so heres more than you asked for... the timer and many other snipits
#ECHO off
MODE CON:COLS=25 LINES=11
cls
color 0B
:taskkill
echo.
echo Program To Shutdown
echo.
set /p taskkill=
if "%taskkill%" == "%taskkill%" goto taskkillconfirm
exit
:taskkillconfirm
color 0B
:image
set image=/im
if "%image%" == "%image%" goto imageconfirm
exit
:imageconfirm
color 0B
:forced
set forced=/f
if "%forced%" == "%forced%" goto forcedconfirm
exit
:forcedconfirm
cls
:hour
color 0B
echo.
echo. Hours?
echo.
set /p hour=
:min
color 0B
cls
echo.
echo Minutes?
echo.
set /p min=
:sec
color 0B
cls
echo.
echo Seconds?
echo.
set /p sec=
:continue
color 0B
cls
echo %taskkill%
echo Program Shutdown in
echo %hour% Hours
echo %min% Minutes
echo %sec% Seconds
set /a sec="%sec%-1"
if %sec%==-1 set /a min="%min%-1"
if %sec%==-1 set /a sec="59"
if %min%==-1 set /a hour="%hour%-1"
if %min%==-1 set /a min="59"
if %hour%==-1 goto done
ping -n 2 127.0.0.1 >NUL
goto continue
:done
color 0B
cls
taskkill %image% %taskkill% %forced%
exit
hope you really enjoy this answer
Simple, try this
#echo off
echo Do you want to read word file or pdf file? Hit any key for options...
pause >nul
echo w for word
echo p for pdf
::set input =
set /p input = Choose your option
if %input% == w goto w
if %input% == p goto p
:w
echo Reading Word file...
::start /your/path/to/your/Office/winword.exe
/path/to/your/doc/file/filename.doc
echo Timer starts
pause >nul
echo 10
ping localhost -n 2 >nul
cls
echo 9
ping localhost -n 2 >nul
cls
echo 8
ping localhost -n 2 >nul
cls
echo 7
ping localhost -n 2 >nul
cls
echo 6
ping localhost -n 2 >nul
cls
echo 5
ping localhost -n 2 >nul
cls
echo 4
ping localhost -n 2 >nul
cls
echo 3
ping localhost -n 2 >nul
cls
echo 2
ping localhost -n 2 >nul
cls
echo 1
ping localhost -n 2 >nul
cls
echo Time's up. Starting the next document...
::you can copy/paste the above commands to start another word file
:p
echo Reading Pdf file...
echo Timer starts
::start /your/path/to/your/Acrobat/acrord32.exe
/path/to/your/pdf/file/filename.pdf
pause >nul
echo 10
ping localhost -n 2 >nul
cls
echo 9
ping localhost -n 2 >nul
cls
echo 8
ping localhost -n 2 >nul
cls
echo 7
ping localhost -n 2 >nul
cls
echo 6
ping localhost -n 2 >nul
cls
echo 5
ping localhost -n 2 >nul
cls
echo 4
ping localhost -n 2 >nul
cls
echo 3
ping localhost -n 2 >nul
cls
echo 2
ping localhost -n 2 >nul
cls
echo 1
ping localhost -n 2 >nul
cls
echo Times up. Starting the next document...
::you can copy/paste the above commands to start another Pdf file

Resources