Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wget - output directory prefix

Tags:

linux

bash

wget

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?

like image 479
WraithLux Avatar asked Jan 24 '12 11:01

WraithLux


People also ask

How do I specify a path in Wget?

When downloading a file, Wget stores it in the current directory by default. You can change that by using the -P option to specify the name of the directory where you want to save the file.

What is -- no parent in Wget?

The ' --no-parent ' option (short ' -np ') is useful in this case. Using it guarantees that you will never leave the existing hierarchy. Supposing you issue Wget with: wget -r --no-parent http://somehost/~luzer/my-archive/

How do I download files from Wget?

Let's start with something simple. Copy the URL for a file you'd like to download in your browser. Now head back to the Terminal and type wget followed by the pasted URL. The file will download, and you'll see progress in realtime as it does.

How do I turn off Wget output?

-q --quiet Turn off Wget's output.


1 Answers

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

like image 188
bkzland Avatar answered Sep 28 '22 02:09

bkzland