Sindhu S
Sindhu S

Reputation: 1022

how to use -o flag in wget with -i?

I understand that -i flag takes a file (which may contain list of URLs) and I know that -o followed by a name can be specified to rename a item being downloaded using wget.

example:

wget -i list_of_urls.txt

wget -o my_custom_name.mp3 http://example.com/some_file.mp3

I have a file that looks like this:

file name: list_of_urls.txt

http://example.com/some_file.mp3 http://example.com/another_file.mp3 http://example.com/yet_another_file.mp3

I want to use wget to download these files with the -i flag but also save each file as 1.mp3, 2.mp3 and so on.

Can this be done?

Upvotes: 2

Views: 1485

Answers (2)

Sindhu S
Sindhu S

Reputation: 1022

I ran a web search again and found https://superuser.com/questions/336669/downloading-multiple-files-and-specifying-output-filenames-with-wget

Wget can't seem to do it but Curl can with -K flag, the file supplied can contain url and output name. See http://curl.haxx.se/docs/manpage.html#-K

If you are willing to use some shell scripting then https://unix.stackexchange.com/questions/61132/how-do-i-use-wget-with-a-list-of-urls-and-their-corresponding-output-files has the answer.

Upvotes: 0

newman
newman

Reputation: 2719

You can use any script language (PHP or Python) for generate batch file. In thin batch file each line will contains run wget with url and -O options.

Or you can try write cycle in bash script.

Upvotes: 0

Related Questions