blob: f70facd08177cb7dc67b2eebe51ba102c9830811 [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():
Tim Peterse6ddc8b2004-07-18 05:56:09 +000011 for p in sys.argv[1:]:
12 makedirs(p)
Guido van Rossumb83ec8f1992-05-19 13:52:02 +000013
14def makedirs(p):
Tim Peterse6ddc8b2004-07-18 05:56:09 +000015 if p and not os.path.isdir(p):
16 head, tail = os.path.split(p)
17 makedirs(head)
18 os.mkdir(p, 0777)
Guido van Rossumb83ec8f1992-05-19 13:52:02 +000019
Johannes Gijsbers7a8c43e2004-09-11 16:34:35 +000020if __name__ == "__main__":
21 main()