Staging
v0.5.1
https://github.com/python/cpython
Raw File
Tip revision: b6b43e00f8ba7ffd142795d2ed2e340e4a897a95 authored by cvs2svn on 08 August 1996, 19:05:09 UTC
This commit was manufactured by cvs2svn to create tag 'r14beta2'.
Tip revision: b6b43e0
makedir.py
#! /usr/local/bin/python

# Like mkdir, but also make intermediate directories if necessary.
# It is not an error if the given directory already exists (as long
# as it is a directory).
# Errors are not treated specially -- you just get a Python exception.

import sys, os

def main():
	for p in sys.argv[1:]:
		makedirs(p)

def makedirs(p):
	if not os.path.isdir(p):
		head, tail = os.path.split(p)
		makedirs(head)
		os.mkdir(p, 0777)

main()
back to top