Return to Snippet

Revision: 35257
at November 4, 2010 20:27 by magicrebirth


Initial Code
import sys
import os


def ensure_dir(f):
    d = os.path.dirname(f)
    if not os.path.exists(d):
        os.makedirs(d)


def main():
	for x in range(150):
                # change this as needed
		filename = "/Users/mac/Desktop/temp/" + str(x+1) + "/"
		ensure_dir(filename)


if __name__ == '__main__':
	main()

Initial URL


Initial Description
save as a file and run....

Initial Title
Creating directories programmatically

Initial Tags
file, path

Initial Language
Python