0
votes

I have a link list with names in the first column and links in the last column. I want to write a script that downloads the files and names the file according to the first column. My code is

#!/bin/bash x="/group/cgl/2018/04/list.dat"

title=$(awk '{print $1}' $x)

Parameter=$(awk '{print $NF}' $x)

youtube-dl -x --audio-format mp3 -o "%("$title")s.%(ext)s" $Parameter

it is able to download and convert the files to mp3 if i leave the

-o "%("$title")s.%(ext)s"

out. Whats wrong with this code, it gives me the error

youtube-dl: error: Cannot download a video and extract audio into the same file! Use "%(heuteXpress.%(ext)s" instead of "%(heuteXpress" as the output template

but fixing it like that doesnt solve it and gives a simmilar error.

1

1 Answers

2
votes

The -o option defines an output template. In an output template, everything in the parentheses in %(...)s is the name of a key.

To add a verbatim text into a template, just write it out, masking % characters with another percent sign, like this:

-o "$(echo "$title" | sed 's/%/%%/g').%(ext)s"

For more information, refer to the official documentation on output templates.