1

I got a bunch of files to download which works great with

wget -i list_of_urls

but my problem is, that wget uses the filename of the downloaded file. Is there a way (or a different tool) which is able to use the whole url als filename, f.e.

http://www.example.com/file1.html
http://www.example.com/file2.html

Lead to the files:

http___www_example_com_file_1.html
http___www_example_com_file_2.html  

2 Answers 2

1

Use some simple bash scripting. For example, if you have a file "foo" with the URLs:

http://www.google.com/index.html
http://www.cnn.com/index.html

You can run:

for i in `cat foo`; do wget $i -O `echo $i | sed 's/[^A-Za-z0-9]/_/g' | sed 's/_html$/.html/'`; done

which produces

http___www_cnn_com_index.html
http___www_google_com_index.html
2
  • 1
    Works like a charm.
    – Karimi
    Commented Nov 11, 2016 at 5:41
  • @Karimi Feel free to upvote the question and answer! Commented Nov 12, 2016 at 17:32
0

Use the "-x" option documented here. For example, given a file "foo" with contents:

http://www.google.com/index.html
http://www.cnn.com/index.html

If you run

wget -x -i foo

then you will get these files:

www.google.com/index.html
www.cnn.com/index.html
1
  • That's nice but I really need a single file with the full name Commented Sep 6, 2015 at 15:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .