blob: 4c00d8880962f250f8f75d03d75666e3a61761ce [file] [log] [blame]
Guido van Rossumf06ee5f1996-11-27 19:52:01 +00001#! /usr/bin/env python
Guido van Rossumb83ec8f1992-05-19 13:52:02 +00002
3# Like mkdir, but also make intermediate directories if necessary.
4# It is not an error if the given directory already exists (as long
5# as it is a directory).
6# Errors are not treated specially -- you just get a Python exception.
7
8import sys, os
9
10def main():
11 for p in sys.argv[1:]:
12 makedirs(p)
13
14def makedirs(p):
Guido van Rossumd9e5d171999-06-09 19:07:22 +000015 if p and not os.path.isdir(p):
Guido van Rossumb83ec8f1992-05-19 13:52:02 +000016 head, tail = os.path.split(p)
17 makedirs(head)
18 os.mkdir(p, 0777)
19
20main()