Aaron Yodaiken
Aaron Yodaiken

Reputation: 19551

create missing directories in path

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.

Upvotes: 8

Views: 4116

Answers (1)

Jochen Ritzel
Jochen Ritzel

Reputation: 107608

os.makedirs does exactly that.

Upvotes: 12

Related Questions