How do I use Wget to download all images into a single folder, from a URL?

geoffs3310 picture geoffs3310 · Jan 5, 2011 · Viewed 263.9k times · Source

I am using wget to download all images from a website and it works fine but it stores the original hierarchy of the site with all the subfolders and so the images are dotted around. Is there a way so that it will just download all the images into a single folder? The syntax I'm using at the moment is:

wget -r -A jpeg,jpg,bmp,gif,png http://www.somedomain.com

Answer

Jon picture Jon · Jan 5, 2011

Try this:

wget -nd -r -P /save/location -A jpeg,jpg,bmp,gif,png http://www.somedomain.com

Here is some more information:

-nd prevents the creation of a directory hierarchy (i.e. no directories).

-r enables recursive retrieval. See Recursive Download for more information.

-P sets the directory prefix where all files and directories are saved to.

-A sets a whitelist for retrieving only certain file types. Strings and patterns are accepted, and both can be used in a comma separated list (as seen above). See Types of Files for more information.