Skip to content

Instantly share code, notes, and snippets.

@larsemil
Created April 19, 2013 12:01
Show Gist options
  • Save larsemil/5419903 to your computer and use it in GitHub Desktop.
Save larsemil/5419903 to your computer and use it in GitHub Desktop.
Small script to create folders when need arise
#!/usr/bin/python
import sys
import os
print sys.argv
if len(sys.argv) < 4:
print "You have to specify atleast three integers: makefolder.py x y z, where x is how many folders, y is how many folders deep and z how many files created in each folder"
def makeFolders(quantity,depth,path = './'):
if depth:
for i in range(0,quantity):
if not os.path.exists(path +'folder'+str(i)):
newpath = path + 'folder' + str(i) + '/'
os.makedirs(newpath)
makeFiles(int(sys.argv[3]), newpath)
makeFolders(quantity,depth-1,newpath)
def makeFiles(quantity,path):
for i in range(0,quantity):
open(path + "file" + str(i),'w').close()
makeFolders(int(sys.argv[1]),int(sys.argv[2]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment