I am doing a kind of special code right here. I am making a code that will create 1 - 10 directories called box1, box2... until 10. In these directories there will be other directories. And in these directories more subdirectories... . At the end, it will generate a key. Here is what I have for now:
import time
import random
import subprocess
import os
import os.path
liste = []
old = []
key = False
numberOfBoxes = 5
files = -1
number = random.randint(1, 10)
def random_generator():
for looper in range(1, numberOfBoxes):
rand = random.randint(1, 10)
liste.append(rand)
def calculate():
c = liste[0]
for looper in range(1, c):
print(looper)
newpath = 'Box' + str(looper)
if not os.path.isdir('./' +newpath+'/'):
os.mkdir('./' +newpath+'/')
def subdir_true():
files = -1
read = liste[0]
chance = random.randint(1, 2)
for looper in range(1, read):
if chance == 1:
for looper in range(1, read):
exist = os.path.exists('Box' + str(looper))
if exist == True:
newpath = 'Box' + str(looper)
old.append(newpath)
files += 1
oldF = old[files]
number = random.randint(1, 10)
for looper in range(1, number):
newpath = 'Box' + str(looper)
os.mkdir('./'+oldF+'/'+newpath+'/')
random_generator()
calculate()
subdir_true()
How do I make subdirectories into subdirectories using for looper in range()?