user2534365
user2534365

Reputation: 215

WGET Download specific folders under an apache directory

I want to download some folders under the same directories by using wget, here is the structure of the apache directory.

example.com/main/eschool/PhotoAlbum/Album/2008-10-13-citieneducationcenter/

example.com/main/eschool/PhotoAlbum/Album/2009-11-12-snfkdgjndfk/

example.com/main/eschool/PhotoAlbum/Album/2012-10-9-dsngosdgndfk/

...

It is found that there is a pattern:

example.com/main/eschool/PhotoAlbum/Album/20*, is it possible to download all those folders?

Upvotes: 8

Views: 10618

Answers (1)

Arman H
Arman H

Reputation: 5618

If you want to download everything under example.com/main/eschool/PhotoAlbum/Album/, but not above it, you can use the --recursive and --no-parent options:

wget --no-parent --recursive http://example.com/main/eschool/PhotoAlbum/Album/

That will download everything below Album directory. If you want to limit how deep wget dives into the subdirectories, you can specify the --level option:

wget --no-parent --recursive --level=3 http://example.com/main/eschool/PhotoAlbum/Album/

That will drill down up to 3 subdirectories below Album.

However, neither of these methods filter by name – they will blindly download everything in a directory, and its subdirectories. If you want more control (e.g. to only download albums beginning with 20*), you'll have to use a shell script, or a scripting language.

Upvotes: 17

Related Questions