blob: 7095868afc6a86b6f6bd5e1d7f4cf3f60a0fff98 [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)
Collin Winter6f2df4d2007-07-17 20:59:35 +000018 os.mkdir(p, 0o777)
Guido van Rossumb83ec8f1992-05-19 13:52:02 +000019
Johannes Gijsbers7a8c43e2004-09-11 16:34:35 +000020if __name__ == "__main__":
21 main()