Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

wget -O for non-existing save path?

Tags:

linux

wget

I can't wget while there is no path already to save. I mean, wget doens't work for the non-existing save paths. For e.g:

wget -O /path/to/image/new_image.jpg http://www.example.com/old_image.jpg 

If /path/to/image/ is not previously existed, it always returns:

No such file or directory 

How can i make it work to automatically create the path and save?

like image 694
夏期劇場 Avatar asked Jun 29 '12 08:06

夏期劇場


People also ask

How do you wget a file to a specific directory?

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. Download the jQuery file you downloaded previously, but this time save it in the Downloads subdirectory.

Can wget download a directory?

Downloading Desired Directories Recursively Probably, mirroring the whole website like above would not be helpful because of its inflexibility. Generally, we would like to get specific directories according to our needs. Fortunately, wget enables us to do so as well.

Will wget overwrite files?

If you specify the output file using the -O option it will overwrite any existing file. Run multiple times will keep over-writting index.

How do I save a file in wget?

By default, downloaded file will be saved with the last name mentioned in the URL. To save file with a different name option O can be used. Syntax: wget -O <fileName><URL>


2 Answers

Try curl

curl http://www.site.org/image.jpg --create-dirs -o /path/to/save/images.jpg 
like image 165
kev Avatar answered Sep 21 '22 14:09

kev


mkdir -p /path/i/want && wget -O /path/i/want/image.jpg http://www.com/image.jpg 
like image 37
Ash Avatar answered Sep 21 '22 14:09

Ash