I have a file with a list of links to some youtube videos.

When I run the command:

wget -i list

Everything works just fine, however wget is automatically renaming the files to the gibberish at the end of each link. Running wget manually is not an option because there are far too many links. How do I go about giving a custom name to the links that wget will recognize?

  • 1
    Can you include an example URL and an example of what it is that wget does to it and what filename you would prefer for wget to use in that case? – Celada Apr 14 '15 at 20:57
  • What are you asking? can you make it more clear? – ctrl-alt-delor Apr 14 '15 at 21:32

The -O option allows you to specify the destination file name. But if you're downloading multiple files at once, wget will save all of their content to the file you specify via -O. Note that in either case, the file will be truncated if it already exists. See the man page for more info.

You can exploit this option by telling wget to download the links one-by-one:

while IFS= read -r url;do
    fileName="blah" # Add a rule to define a new name for each file here
    wget -O "$fileName" "$url"
done < list

You can also take JJoao's suggestion and add a file name next to each URL in the file then do:

while IFS= read -r url fileName;do
    wget -O "$fileName" "$url"
done < list

where it is assumed you have added a (unique) file name after each URL in the file (separated by a space).


Make it simple, do not complicate ur life...

make a bash script call it list.sh and add the lines

wget url -O your-filename 
wget url2 -O your-filename2

as many as you want, and make it executable

chmod 775 list.sh

the run it ./list.sh

  • 3
    Even though the answer does not technically address the problem, it sheds some damn deep philosophical light on our way of thinking as human beings. +1. – sepehr Aug 24 '16 at 17:45
  • 2
    If i want to get 50 files should i write it 50 times? This is why have scripts for. To make our life easier. – George Vasiliou Mar 18 '17 at 0:07

You may want to take a look at youtube-dl manpage.

youtube-dl -a URL-file -o '-o "%(autonumber)s-%(title)s.%(ext)s"


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.