Wget - output directory prefix

14,407

You can combine --no-directories if you want all your files inside one directory or --no-host-directories to have subdirectories but no subdirectories per host with your --directory-prefix option.

2.6 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’).

‘-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.

‘-P prefix’ ‘--directory-prefix=prefix’ Set directory prefix to prefix. The directory prefix is the directory where all other files and subdirectories will be saved to, i.e. the top of the retrieval tree. The default is ‘.’ (the current directory). (From the wget manual.)

Share:
14,407
WraithLux
Author by

WraithLux

Updated on June 18, 2022

Comments

  • WraithLux
    WraithLux almost 2 years

    Currently I try to use:

    "wget --user=xxx --password=xxx -r ftp://www.domain.com/htdocs/"
    

    But this saves output files to current directory in this fashion:

    curdir/www.domain.com/htdocs/*
    

    I need it to be:

    curdir/*
    

    Is there a way to do this, I only see a way to use output prefix, but i think this will just allow me to define directory outside current dir?