Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WGET Download specific folders under an apache directory

Tags:

wget

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?

like image 681
user2534365 Avatar asked Jun 29 '13 10:06

user2534365


1 Answers

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.

like image 159
Arman H Avatar answered Oct 12 '22 03:10

Arman H