I have a variable %data%
in a Windows batch file which has variable information in the following format:
URL_A
TEXT
URL_B
So essentially, three strings separated by two newline
characters. The length of each string varies on each run. I need to split these three lines into three separate variables. The FOR
command seemed promising but there doesn't seem to be a way to specify a newline
delimiter for the delim=
option.
EDIT (as requested by @Compo):
Here is the batch file's syntax:
play_vid.bat -stream <VID_HEIGHT> <START-TIME> <URL>
Here is the command that generates the %data%
variable in my batch file (requires youtube-dl
to be installed within the %PATH%
environment variable to work):
FOR /F "skip=1 delims=" %%a IN ('youtube-dl --get-title -g -f "bestvideo[height<=%2][fps<=30],worstaudio" --no-playlist "%4"') DO @set data=%%a
Here is a sample command with all the batch variables resolved so that it can be run directly from cmd to test and view the contents of the %data%
variable:
FOR /F "skip=1 delims=" %a IN ('youtube-dl --get-title -g -f "bestvideo[height<=1080][fps<=30],worstaudio" --no-playlist "https://www.youtube.com/watch?v=ltynWs_LtIw"') DO @echo %a
For this particular example, %data%
will contain:
https://manifest.googlevideo.com/api/manifest/dash/expire/1592941694/ei/HgjyXvilD4ndwQG3nrzoBg/ip/[redacted]
How To Stabilize GoPro Video for Free with FFMPEG
https://manifest.googlevideo.com/api/manifest/dash/expire/1592941694/ei/HgjyXvilD4ndwQG3nrzoBg/ip/[redacted]
that is,
line 1: The URL of the video (DASH) stream.
line 2: The title of the video.
line 3: The URL of the audio (DASH) stream.