Wget - if / else download condition?

Posted by Kai on Super User See other posts from Super User or by Kai
Published on 2012-04-13T15:04:26Z Indexed on 2012/04/13 17:34 UTC
Read the original article Hit count: 347

Filed under:
|
|
|
|

I want wget to prefer a certain filetype over another, if the files have the same basename.

For example:

if foo.ogg available, don't download foo.mp3


the way i use wget so far to crawl/automatically download (if anyone is interested):

wget -Dfoo.com -I /folder/ -r -l 1 -nc -A.ogg,.mp3 -i http://www.foo.com/folder/

but this, of course, gets me .mp3 AND .ogg files. It often also gets me image files like .png which i didn't want in the first place, and discards them afterwards. Any Ideas?

  • (Syntax-Explanation:
    -D: download only from this Domain
    -I: download only from this subfolder of Domain
    -r: recursive (follow links and directory structure)
    -l 1: follow only 1 link deep
    -nc: no clobber = download only if file doesn't exist
    -A: accept/download only all *.ogg and *.mp3 (discard necessary html-files)
    -i: download-url/starting point)

© Super User or respective owner

Related posts about bash

Related posts about download