Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

create missing directories in path

Tags:

python

Is there a clean way of taking a path like this:

/foo/bar/faz/baz/

where foo and bar exist, but faz and baz don't, and create create faz and baz while leaving foo and bar alone? (Of course, this should work for something like exists/exists/exists/doesnt_exist/doesnt_exit/doesnt_exist/doesnt_exist or whatever (number of non existants/existants is variable) too.

Thanks!

like image 968
Aaron Yodaiken Avatar asked Jan 02 '11 21:01

Aaron Yodaiken


1 Answers

os.makedirs does exactly that.

like image 128
Jochen Ritzel Avatar answered Sep 28 '22 09:09

Jochen Ritzel