I was trying to use yt-dlp to download some mp3 files ... for research.
I wanted to wrap the whole command line prompt into a batch script, so the only thing I would input would be the link, but I can't seem to get it to pass the parameter through it, even though I can echo it. Any help would be greatly appreciated.
It works if I type into the command line prompt manually.
@echo off
echo Argument 1: %1
yt-dlp -x --audio-format mp3 --audio-quality 0 -o "%(title)s.mp3" %1
Output
mp3.bat
Argument 1:
Usage: yt-dlp [OPTIONS] URL [URL...]
yt-dlp: error: You must provide at least one URL.
Type yt-dlp --help to see a list of all options.
I was trying to use yt-dlp to download some mp3 files ... for research.
I wanted to wrap the whole command line prompt into a batch script, so the only thing I would input would be the link, but I can't seem to get it to pass the parameter through it, even though I can echo it. Any help would be greatly appreciated.
It works if I type into the command line prompt manually.
@echo off
echo Argument 1: %1
yt-dlp -x --audio-format mp3 --audio-quality 0 -o "%(title)s.mp3" %1
Output
mp3.bat https://www.youtube/watch?v=Dq3V-KdKslU
Argument 1: https://www.youtube/watch?v
Usage: yt-dlp [OPTIONS] URL [URL...]
yt-dlp: error: You must provide at least one URL.
Type yt-dlp --help to see a list of all options.
Share
Improve this question
asked Jan 30 at 7:33
Michael LMichael L
394 bronze badges
3
|
2 Answers
Reset to default 2= is treated as a delimiter and the rest of the url is in %2. You may try quoting the parameter to the batch file or if that is not possible, %*
contains all the parameters.
Everything that is not a batch variable nor parameter needs its % doubled to escape it.
yt-dlp -x --audio-format mp3 --audio-quality 0 -o "%%(title)s.mp3" %*
No, you did not echo the entire %1
. As I can see, =Dq3V-KdKslU
is stripped.
The issue is the character =
. To avoid stripping, you can enter this argument in quotation marks. Also, you can use %~1
instead of %1
:
> mp3.bat "https://www.youtube/watch?v=Dq3V-KdKslU"
Then the entire argument string will be passed. In your echo, you will see
Argument 1: https://www.youtube/watch?v=Dq3V-KdKslU
Still, you can use %1
in the batch file if you want to include quotation marks. With %1
, you will get
Argument 1: "https://www.youtube/watch?v=Dq3V-KdKslU"
This value will be correctly passed to yt-dlp
and elsewhere.
"%(title)s.mp3"
, so you getyt-dlp -x --audio-format mp3 --audio-quality 0 -o "%%(title)s.mp3" %1
– jeb Commented Jan 30 at 7:35%~1
to remove the quotes – Magoo Commented Jan 30 at 7:49