0

I'm currently doing this:

wget -i download.txt -x

It creates a root directory example.org/. What I'd like to do is only create subdirectories.

Is there a way to compel wget into doing what I'd like?

3

According to the man page the parameter -nH should do what you are looking for:

   Directory Options
   -nd
   --no-directories
       Do not create a hierarchy of directories when retrieving recursively.  With this option turned on, all
       files will get saved to the current directory, without clobbering (if a name shows up more than once,
       the filenames will get extensions .n).

   -x
   --force-directories
       The opposite of -nd---create a hierarchy of directories, even if one would not have been created
       otherwise.  E.g. wget -x http://fly.srk.fer.hr/robots.txt will save the downloaded file to
       fly.srk.fer.hr/robots.txt.

   -nH
   --no-host-directories
       Disable generation of host-prefixed directories.  By default, invoking Wget with -r
       http://fly.srk.fer.hr/ will create a structure of directories beginning with fly.srk.fer.hr/.  This
       option disables such behavior.

I'm not shure that you really need the -i param used in your example.

From my point of view, to achieve what you described is enough to run:

wget -xnH download.txt
  • Oh I thought I tried that but it works now. Thanks! – Kit Sunde Oct 9 '15 at 15:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.