Q:

Wget download files using lins in a file and rename

I have file with links separated by \n.
And I also have a file containing new names for each of links.
Is there a way to download files and rename them using only wget?
I do this because I took these links from a webpage where the link has a
hash of a filename in the end but the actual name of the file is stored in a description of the html element. 

A:

Python solution:
#-*- coding:utf-8 -*-
import os
import urllib2

with open('path_to_your_hash_url', 'r') as fh:
    url_to_be_download = fh.read().split("\n")

with open('path_to_your_FileNames', 'r') as fh:
    fileNames = fh.read().split('\n')

siteurl = 'http://whatever.com/'  #path to your site

downloadFolder = r'YourDownloadFile folder'

for i, url in enumerate(url_to_be_download):
    location = os.path.join(downloadFolder, url_to_be_download[i])
    with open(newloc,"w") as fh:
        full_url = siteurl+ url
        ufile = urllib2.urlopen(full_url).read()
        fh.write(ufile)

