18

I am trying to download all of the files in a directory using:

wget -r -N --no-parent -nH -P /media/karunakar --ftp-user=jsjd --ftp-password='hdshd' ftp://ftp.xyz.com/Suppliers/my/ORD20130908

but wget is fetching files from the parent directory, even though I specified --no-parent. I only want the files in ORD20130908.

Arman H
  • 5,488
  • 10
  • 51
  • 76
Karunakar
  • 2,209
  • 4
  • 15
  • 20

2 Answers2

31

You need to add a trailing slash to indicate the last item in the URL is a directory and not a file:

wget -r -N --no-parent -nH -P /media/karunakar --ftp-user=jsjd --ftp-password='hdshd' ftp://ftp.xyz.com/Suppliers/my/ORD20130908

wget -r -N --no-parent -nH -P /media/karunakar --ftp-user=jsjd --ftp-password='hdshd' ftp://ftp.xyz.com/Suppliers/my/ORD20130908/

From the documentation:

Note that, for HTTP (and HTTPS), the trailing slash is very important to ‘--no-parent’. HTTP has no concept of a “directory”—Wget relies on you to indicate what’s a directory and what isn’t. In ‘http://foo/bar/’, Wget will consider ‘bar’ to be a directory, while in ‘http://foo/bar’ (no trailing slash), ‘bar’ will be considered a filename (so ‘--no-parent’ would be meaningless, as its parent is ‘/’).

joelostblom
  • 43,590
  • 17
  • 150
  • 159
Synetech
  • 9,643
  • 9
  • 64
  • 96
4
wget -r -N --no-parent -nH -P /media/karunakar --ftp-user=jsjd --ftp-password='hdshd'  -I/ORD20130908 ftp://ftp.xyz.com/Suppliers/my

See wget document for the use of -I flag

nhahtdh
  • 55,989
  • 15
  • 126
  • 162
EncomX
  • 81
  • 1
  • 5