Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

So the -k option (or --convert-link) will convert links in your web pages to relative after the download finishes, such as the man page says:

After the download is complete, convert the links in the document to makethem suitable for local viewing. This affects not only the visible hyperlinks, but anypart of the document that links to external content, such as embedded images, links to style sheets, hyperlinks to non-HTML con- tent, etc.

So, if I didn't specify -k, can I run wget again after the download and fix that, and if so, what would be the proper command? My guess is wget -c [previous options used] [url] and run it in the same working directory as the file were downloaded to.

share|improve this question
1  
you could certainly post-process the files after download, but i don't know if wget does this. your idea of trying it with -c is a good one. time to experiment! –  quack quixote Dec 7 '09 at 21:08
    
Have a utility handy to convert the links, by any chance? Running on Windows, by the way... –  Nathaniel Dec 7 '09 at 21:14
    
perl ... no prewritten script, but if i wanted a DIY solution that's what i'd use –  quack quixote Dec 7 '09 at 21:48
    
Okay, thanks. Don't have Perl installed and it would take too long to grab it. Fortunately, I found how to make wget do the job. I posted an answer. –  Nathaniel Dec 7 '09 at 21:52
    
btw, ActivePerl is around as a windows perl port; it's a fairly small installer, and i'm pretty sure most CPAN modules work with it. activestate.com/activeperl –  quack quixote Dec 8 '09 at 15:47

1 Answer 1

up vote 8 down vote accepted

Yes, you can make wget do it. I'd say use wget -nc -k [previous options] [previous url]. -nc is no-clobber. From the man page:

When −nc is specified, this behavior is suppressed, and Wget will refuse to download newer copies of file.

And the -k option does the link converting. So... wget starts digging in the remote server, sees all the files you already have, refuses to redownload them, and then edits the HTML links to relative when it's done. Nice.

share|improve this answer
    
+1 for experimentation! –  quack quixote Dec 8 '09 at 15:44
1  
No this doesn't work for me. He download the first file (e.g. index.html), see that is allready downloaded an stop. If you want wget working recursive you have to use the timestamp (-K) option. So wget must request all headers to match if the file is newer or not. –  user89733 Jul 10 '11 at 21:51
3  
GNU Wget 1.13.3 built on darwin11.1.0. Trying to use both options at the same time gives Both --no-clobber and --convert-links were specified,only --convert-links will be used. –  Ludovic Kuty Dec 29 '11 at 4:05
    
didn't your question ask for without -k? –  barlop Jan 21 '12 at 1:34
    
Cf. @LudovicKuty's comment -- as of wget 1.13 --no-clobber doesn't work with --convert-links. See http://savannah.gnu.org/bugs/?31781 for details. –  David Moles Feb 26 '13 at 20:37

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.