Skip to content

Instantly share code, notes, and snippets.

@jayrambhia
Created February 10, 2012 10:44
Show Gist options
  • Save jayrambhia/1788704 to your computer and use it in GitHub Desktop.
Save jayrambhia/1788704 to your computer and use it in GitHub Desktop.
Create directories (eg. home/user/direc1/direc2/direc3/direc4) even if direc1, direc2, direc3 doesn't exist. It will create all the directories. Just give absolute path.
import os
def makeDir(path):
if os.path.isdir(path):
return
dir1, dir2 = os.path.split(path)
makeDir(dir1)
os.mkdir(path)
return
# path - Absolute path
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment