How to use wget with an input file and filenames

Posted by Matt on Super User See other posts from Super User or by Matt
Published on 2012-11-20T22:16:18Z Indexed on 2012/11/20 23:06 UTC
Read the original article Hit count: 253

Filed under:
|

i have a text file that contains 10,000 url's with a unique number i want to save the file as. Each line has a 10 character code, then the URL of the image to retrieve. How can I make the input file use the first 10 characters as the wget filename?

this is an example of the input file: input.txt

x100083590http://image.allmusic.com/13/adg/cov200/drt200/t291/t29123q8m19.jpg
b200149548http://ecx.images-amazon.com/images/I/41DoH%2BAWKEL.jpg
z100151855http://image.allmusic.com/13/amg/cov200/dri400/i450/i45035hxdrb.jpg
p400171646http://ecx.images-amazon.com/images/I/61cH4n34IhL.jpg

wget -i input.txt would get the file but not with the preceding unique number.

I want t29123q8m19.jpg (the first line) to be saved as x100083590.jpg

If there is a better way to write out the input file, say with the URL first, then I can do that too, but I will never know the length of the first field. Right now the first 10 characters will always be what I want to save the wget image as.

Edit This is being done in a windows environment.

© Super User or respective owner

Related posts about wget

Related posts about input