Sign up ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

wget -O /path/to/image/new_image.jpg

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

No such file or directory

How can i make it work?

share|improve this question
Oh, you need the non-existential version... it can download things to places that don't exist! Of course, you'll need a non-existential version of ls to see them though. – lornix Jun 29 '12 at 10:47

2 Answers 2

You can create the dir manually before run with

mkdir -p /path/to/image/

Or even write function that will do it itself and put it in ~/.bashrc or whatever shell you use:

wget_mkdir() {
    mkdir -p $2
    wget $@

don't forget to add it to current session with . ~/.bashrc

Or even just run in the shell

function wget_mkdir() { mkdir -p ${2%/*} ; wget $@ ; }

and start use it immediately as:

wget_mkdir -O /path/to/image/new_image.jpg
share|improve this answer

Is this your looking for "--directory-prefix=prefix" ... if so try as

wget --directory-prefix=/path/to/image/

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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