Score:-1

wget to download files from list of urls and naming it from other list of names

jp flag

I Have two text files - one of them contains urls of images that I want to download and other text file has the list of names corresponding to the urls of first files.

Example content of text file 1:

www.img.com/1/
www.img.com/2/
www.img.com/3/

Example Content of text file 2:

ab.jpg
bc.jpg
cd.jpg

I know how to use wget command for a list of urls :

wget -i exampletextfile1.txt

Is there any way or syntax to download files from first text file using wget and name them with respect to corresponding names from other text file?

Timothy Truckle avatar
kr flag
I'd say you need to write a script that [reads both files into arrays](https://stackoverflow.com/a/19494945) an then iterates over them calling `wget` in each loop.
vanadium avatar
cn flag
As you write it, contents of text file 1 are *not* URL's to images. They are URL's to directories on the internet, so will display an "index.html" file if it exists.
Score:0
cn flag

You can merge files into one using the paste tool:

paste -d "" file1.txt file2.txt > result.txt

The result of merging your examples:

www.img.com/1/ab.jpg
www.img.com/2/bc.jpg
www.img.com/3/cd.jpg
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.