Discussion:
yt-dlp "--batch-file" execution
(too old to reply)
j***@astraweb.com
2024-07-08 19:31:15 UTC
Permalink
win 7 home premium

Has anyone used the yt-dlp "--batch file" parameter and had a successful execution?

This is as far as i have gotten:

~~~~
c:\youtube-dl_13:41:31.62_>yt-dlp -a --batch-file C:\youtube-dl\ytdlpbatch.txt
ERROR: batch file --batch-file could not be read

c:\youtube-dl_13:42:12.13_>
~~~~

I think i need syntax help

ytdlpbatch.txt -- the file containing the two test urls (real), one per line, each in quotes --



jack
J. P. Gilliver
2024-07-08 20:20:07 UTC
Permalink
Post by j***@astraweb.com
win 7 home premium
Has anyone used the yt-dlp "--batch file" parameter and had a
successful execution?
~~~~
c:\youtube-dl_13:41:31.62_>yt-dlp -a --batch-file C:\youtube-dl\ytdlpbatch.txt
ERROR: batch file --batch-file could not be read
c:\youtube-dl_13:42:12.13_>
~~~~
I think i need syntax help
ytdlpbatch.txt -- the file containing the two test urls (real), one per
line, each in quotes --
http://youtu.be/tRYpgfWDx2U
http://youtu.be/ek5MaXICwRo
jack
Since you're already in c:\youtube-dl, try just

yt-dlp -a --batch-file ytdlpbatch.txt

If that works, it means something - either yt-dlp, or the cmd
interpreter - doesn't like the path having a "-" in it.

You could also try with the filename parameter in "", either with or
without the C:\youtube-dl part.

I know having a space in the pathname stops the -U (update) function
from working (because it makes - and then deletes - a batch file to do
the shenanigans needed to do an update, and having a space in the path
name [such as Program Files] breaks that). "--batch-file could not be
read" suggests it didn't get as far as parsing the batch file contents,
which may be OK.
--
J. P. Gilliver. UMRA: 1960/<1985 MB++G()AL-IS-Ch++(p)***@T+H+Sh0!:`)DNAf

The death of democracy is not likely to be an assassination from ambush.
It will be a slow extinction from apathy, indifference, and undernourishment.
-Robert Maynard Hutchins, educator (1899-1977)
j***@astraweb.com
2024-07-09 03:07:59 UTC
Permalink
Post by J. P. Gilliver
Post by j***@astraweb.com
win 7 home premium
Has anyone used the yt-dlp "--batch file" parameter and had a
successful execution?
~~~~
c:\youtube-dl_13:41:31.62_>yt-dlp -a --batch-file C:\youtube-dl\ytdlpbatch.txt
ERROR: batch file --batch-file could not be read
c:\youtube-dl_13:42:12.13_>
~~~~
I think i need syntax help
ytdlpbatch.txt -- the file containing the two test urls (real), one per
line, each in quotes --
http://youtu.be/tRYpgfWDx2U
http://youtu.be/ek5MaXICwRo
jack
Since you're already in c:\youtube-dl, try just
yt-dlp -a --batch-file ytdlpbatch.txt
If that works, it means something - either yt-dlp, or the cmd
interpreter - doesn't like the path having a "-" in it.
You could also try with the filename parameter in "", either with or
without the C:\youtube-dl part.
I know having a space in the pathname stops the -U (update) function
from working (because it makes - and then deletes - a batch file to do
the shenanigans needed to do an update, and having a space in the path
name [such as Program Files] breaks that). "--batch-file could not be
read" suggests it didn't get as far as parsing the batch file contents,
which may be OK.
Thanks for the response.

Actually, I tried all of those permutations. Plus several more.

I just wondered if anyone had gotten it to work and perhaps and example i could replicate.
Java Jive
2024-07-08 20:35:26 UTC
Permalink
Post by j***@astraweb.com
win 7 home premium
Has anyone used the yt-dlp "--batch file" parameter and had a successful execution?
~~~~
c:\youtube-dl_13:41:31.62_>yt-dlp -a --batch-file C:\youtube-dl\ytdlpbatch.txt
ERROR: batch file --batch-file could not be read
c:\youtube-dl_13:42:12.13_>
~~~~
I think i need syntax help
ytdlpbatch.txt -- the file containing the two test urls (real), one per line, each in quotes --
http://youtu.be/tRYpgfWDx2U
http://youtu.be/ek5MaXICwRo
You've specified both the short '-a' and the long '--batch-file'
versions of the same command-line parameter, hence the program, on
encountering the '-a' expects to find a file parameter next, but instead
find '--batch-file' which it interprets as a file, hence the message:
'ERROR: batch file --batch-file could not be read'!

Use either the short or the long version of the parameter, but not both
together.
--
Fake news kills!

I may be contacted via the contact address given on my website:
www.macfh.co.uk
j***@astraweb.com
2024-07-09 02:59:29 UTC
Permalink
Post by Java Jive
Post by j***@astraweb.com
win 7 home premium
Has anyone used the yt-dlp "--batch file" parameter and had a successful execution?
~~~~
c:\youtube-dl_13:41:31.62_>yt-dlp -a --batch-file C:\youtube-dl\ytdlpbatch.txt
ERROR: batch file --batch-file could not be read
c:\youtube-dl_13:42:12.13_>
~~~~
I think i need syntax help
ytdlpbatch.txt -- the file containing the two test urls (real), one per line, each in quotes --
http://youtu.be/tRYpgfWDx2U
http://youtu.be/ek5MaXICwRo
You've specified both the short '-a' and the long '--batch-file'
versions of the same command-line parameter, hence the program, on
encountering the '-a' expects to find a file parameter next, but instead
'ERROR: batch file --batch-file could not be read'!
Use either the short or the long version of the parameter, but not both
together.
Thanks for the response.
Yes, i realize that and originally only had the --batch-file parm and got nowhere until i put the -a,
also, and it gave the error message. I am looking for an example of what works.....
VanguardLH
2024-07-09 03:58:57 UTC
Permalink
Post by j***@astraweb.com
Yes, i realize that and originally only had the --batch-file parm and
got nowhere until i put the -a, also, and it gave the error message.
I am looking for an example of what works.....
So, instead of running:

yt-dlp -a --batch-file C:\youtube-dl\ytdlpbatch.txt

which complains "--batch-file" is not a valid filespec, you're saying:

yt-dlp --batch-file C:\youtube-dl\ytdlpbatch.txt

also doesn't work, but apparently issues no error message (sorry, "go
nowhere" doesn't really say what happens), and doesn't procede to
capture the video streams at the specified URLs.

Instead of specifying a path to the .txt file, what happens if you copy
the .txt file into the same folder (c:\youtube-dl_13:41:31.62_) as where
you find and run yt-dlp.exe? After changing the default directory to
c:\youtube-dl_13:41:31.62_ in the command shell, you'd end up running:

yt-dlp --batch-file ytdlpbatch.txt

I mention this possible restriction due to mention at:

https://github.com/edinsuta/yt-dlp-batch
"Note that the yt-dlp.exe file must be stored in the same directory as
the .bat files in order to work."

That's for the .bat (batch) files to facilitate using yt-dlp, but
perhaps there is a similar restriction to yt-dlp.exe and the text file
you specify on its command line. The help for yt-dlp says the parm
sytax is "--batch-file FILE", but doesn't say where the file can or must
be. I didn't find mention of what atoms/tokens are permitted in the
filespec.

Obviously you need execute permission in the folder where it yt-dlp.exe,
and read permission in the .txt file folder referenced by --batch-file
parm's filespec. You can run yt-dlp.exe okay, right? Can you open the
.txt file listing the URLs in Notepad? Make sure to copy copy the
filespec string in your command to specify what file to open in Notepad,
so your eyes aren't making an auto-correction versus where is actually
the file.

Did you create the .txt file using a Linux or Windows host? Line
delimiters (aka line breaks) differ between those. DOS/Windows uses
CR+LF (carriage return and line feed) or \r\n (return and newline) while
Linux only needs LF (linefeed) or just \n. Back in teletype days, CR
returned the head to the left end of the platen while LF simply rolled
the platen forward. So, a LF would start printing in the next line, but
starting at the same position as the last character in the prior line,
not at the left end. This encumberance happens when folks write text
files on Linux, and expect them to be properly interpreted on Windows.

Also try encompassing the filespec with double-quote characters.
Normally those would only be needed if the file or its path contained
space characters, but quoting the filespec might also aid the parser.

Rather than a text file listing the URLs of where to capture videos,
does yt-dlp work when you directly specify the URLs on the command line?
Like running:

yt-dlp [url],[url],[url]
J. P. Gilliver
2024-07-09 06:16:05 UTC
Permalink
Post by j***@astraweb.com
Post by Java Jive
Post by j***@astraweb.com
win 7 home premium
Has anyone used the yt-dlp "--batch file" parameter and had a successful execution?
[]
Post by j***@astraweb.com
Post by Java Jive
You've specified both the short '-a' and the long '--batch-file'
versions of the same command-line parameter, hence the program, on
encountering the '-a' expects to find a file parameter next, but instead
'ERROR: batch file --batch-file could not be read'!
Use either the short or the long version of the parameter, but not both
together.
Thanks for the response.
Yes, i realize that and originally only had the --batch-file parm and
got nowhere until i put the -a,
also, and it gave the error message. I am looking for an example of what works.....
Your use of the word "also" is a little concerning: I think JJ and
others are saying you should use -a OR the long form, NOT both.

[Ignore my previous post about -, quotes, and spaces - that was before I
read the other responses.]

If you're going to the bother of making a batch file containing URLs,
you could just add "y " before each URL in the batch file (assuming
you'd renamed - or copied - yt-dlp.exe to y.exe, as I have), and then
you could just run the batch file.
--
J. P. Gilliver. UMRA: 1960/<1985 MB++G()AL-IS-Ch++(p)***@T+H+Sh0!:`)DNAf

"Not an electronic sausage!"
j***@astraweb.com
2024-07-09 10:47:52 UTC
Permalink
Post by J. P. Gilliver
Your use of the word "also" is a little concerning: I think JJ and
others are saying you should use -a OR the long form, NOT both.
[Ignore my previous post about -, quotes, and spaces - that was before I
read the other responses.]
If you're going to the bother of making a batch file containing URLs,
you could just add "y " before each URL in the batch file (assuming
you'd renamed - or copied - yt-dlp.exe to y.exe, as I have), and then
you could just run the batch file.
I agree, and i have done this sort of thing in a "klunky" boilerplated way before.

Using the batch-file parm would be more elegant but i am looking at doing this for a one time situation
and am exceeding the time of doing it the tried and true way of stacking commands as a bat file and
doing it that way. which is what i think I will do.

I spent a couple of hours on permutations of command structure yesterday and was only looking for an
example that worked.

thanks,

jim
J. P. Gilliver
2024-07-09 12:40:10 UTC
Permalink
[]
Post by j***@astraweb.com
Post by J. P. Gilliver
If you're going to the bother of making a batch file containing URLs,
you could just add "y " before each URL in the batch file (assuming
you'd renamed - or copied - yt-dlp.exe to y.exe, as I have), and then
you could just run the batch file.
I agree, and i have done this sort of thing in a "klunky" boilerplated way before.
Using the batch-file parm would be more elegant but i am looking at
doing this for a one time situation
and am exceeding the time of doing it the tried and true way of
stacking commands as a bat file and
doing it that way. which is what i think I will do.
I spent a couple of hours on permutations of command structure
yesterday and was only looking for an
example that worked.
[]
I don't know about when the whole command -

y URL

- is included in a batch file. I found that for my subtitle batch file,
ys.bat (which contains just

y --write-subs %1

), I had to call it with

ys "URL"

, i. e. with the URL in quotes. (This was/is a function of the cmd
parser, not any limitation of yt-dlp.) You may or may not need to put
the URLs in quotes if you make a batch file of complete commands.
--
J. P. Gilliver. UMRA: 1960/<1985 MB++G()AL-IS-Ch++(p)***@T+H+Sh0!:`)DNAf

The web is a blank slate; you can't design technology that is 'good'. You can't
design paper that you can only write good things on. There are no good or evil
tools. You can put an engine in an ambulance or a tank. - Sir Tim Berners-Lee,
Radio Times 2009-Jan-30 to -Feb-5.
j***@astraweb.com
2024-07-09 13:40:10 UTC
Permalink
Post by J. P. Gilliver
[]
Post by j***@astraweb.com
Post by J. P. Gilliver
If you're going to the bother of making a batch file containing URLs,
you could just add "y " before each URL in the batch file (assuming
you'd renamed - or copied - yt-dlp.exe to y.exe, as I have), and then
you could just run the batch file.
I agree, and i have done this sort of thing in a "klunky" boilerplated way before.
Using the batch-file parm would be more elegant but i am looking at
doing this for a one time situation
and am exceeding the time of doing it the tried and true way of
stacking commands as a bat file and
doing it that way. which is what i think I will do.
I spent a couple of hours on permutations of command structure
yesterday and was only looking for an
example that worked.
[]
I don't know about when the whole command -
y URL
- is included in a batch file. I found that for my subtitle batch file,
ys.bat (which contains just
y --write-subs %1
), I had to call it with
ys "URL"
, i. e. with the URL in quotes. (This was/is a function of the cmd
parser, not any limitation of yt-dlp.) You may or may not need to put
the URLs in quotes if you make a batch file of complete commands.
It works just fine where the URL is in the batch file -- it is just static at execution (can't be
changed)
(I have done it numerous times)

Your 'ys' bat allows you to change the url addressed -- but I guess you found the necessity of the %1 to
allow it to be variable.

jim
J. P. Gilliver
2024-07-09 21:10:02 UTC
Permalink
[]
Post by j***@astraweb.com
Post by J. P. Gilliver
- is included in a batch file. I found that for my subtitle batch file,
ys.bat (which contains just
y --write-subs %1
), I had to call it with
ys "URL"
, i. e. with the URL in quotes. (This was/is a function of the cmd
parser, not any limitation of yt-dlp.) You may or may not need to put
the URLs in quotes if you make a batch file of complete commands.
It works just fine where the URL is in the batch file -- it is just
static at execution (can't be
changed)
(I have done it numerous times)
Your 'ys' bat allows you to change the url addressed -- but I guess you
found the necessity of the %1 to
allow it to be variable.
jim
Well, I just wanted a quick way of downloading a video with subtitles,
which I don't always want (they're not needed for instrumental music,
such as orchestral, for example), without having to remember or type the
" --write-subs" bit.
--
J. P. Gilliver. UMRA: 1960/<1985 MB++G()AL-IS-Ch++(p)***@T+H+Sh0!:`)DNAf

The early worm gets the bird.
Paul
2024-07-09 07:18:00 UTC
Permalink
Post by j***@astraweb.com
Post by Java Jive
Post by j***@astraweb.com
win 7 home premium
Has anyone used the yt-dlp "--batch file" parameter and had a successful execution?
~~~~
c:\youtube-dl_13:41:31.62_>yt-dlp -a --batch-file C:\youtube-dl\ytdlpbatch.txt
ERROR: batch file --batch-file could not be read
c:\youtube-dl_13:42:12.13_>
~~~~
I think i need syntax help
ytdlpbatch.txt -- the file containing the two test urls (real), one per line, each in quotes --
http://youtu.be/tRYpgfWDx2U
http://youtu.be/ek5MaXICwRo
You've specified both the short '-a' and the long '--batch-file'
versions of the same command-line parameter, hence the program, on
encountering the '-a' expects to find a file parameter next, but instead
'ERROR: batch file --batch-file could not be read'!
Use either the short or the long version of the parameter, but not both
together.
Thanks for the response.
Yes, i realize that and originally only had the --batch-file parm and got nowhere until i put the -a,
also, and it gave the error message. I am looking for an example of what works.....
You have four combinations to check.

-a # Indicates a batchfile
--batch-file # Indicates a batchfile

"C:\youtube-dl\ytdlpbatch.txt" # An absolute path, with double quotes if any spaces are present.

"ytdlpbatch.txt" # A path relative to the current working directory, with double quotes
# if any space characters are present in the name

So that's four tries total.

cd /d c:\youtube-dl_13:42:12.13_ # Set the current working directory first
# Does Windows accept the usage of these characters ? ":"

yt-dlp -a "C:\youtube-dl\ytdlpbatch.txt" # strictly speaking, none of these need double quotes
yt-dlp -a "ytdlpbatch.txt" # This one only works if c:\youtube-dl_13:42:12.13_\ytdlpbatch.txt exists

yt-dlp --batch-file "C:\youtube-dl\ytdlpbatch.txt" # This is an absolute path, that points outside the $CWD
yt-dlp --batch-file "ytdlpbatch.txt" # This one only works if c:\youtube-dl_13:42:12.13_\ytdlpbatch.txt exists

Paul
VanguardLH
2024-07-08 20:42:56 UTC
Permalink
Post by j***@astraweb.com
Has anyone used the yt-dlp "--batch file" parameter and had a successful execution?
~~~~
c:\youtube-dl_13:41:31.62_>yt-dlp -a --batch-file C:\youtube-dl\ytdlpbatch.txt
ERROR: batch file --batch-file could not be read
c:\youtube-dl_13:42:12.13_>
~~~~
I think i need syntax help
From https://github.com/yt-dlp/yt-dlp#general-options, it looks like you
use either -a, or --batch-file, but not both. Since parsing probably
sees the -a argument first, it thinks --batch-file is the name of a
file, not another same-function argument.

Looks like Jive came to same conclusion. The comma in listing arguments
means use one or the other, not both. Try with just -a, or just
--batch-file. I'd probably use the latter longer argument name as it is
self-documenting when you later review your command line.
Loading...