I'm trying to write a python script which will traverse through a directory recursively and create files of different sizes inside all of them. So far I have reached here. Well I haven't written any mechanism for creating files with different sizes but I need it. I very well know there's something wrong with the file creation logic I have written. Any help is highly appreciable.
for dirs in os.walk('/home/zarvis'):
filename = str(uuid.uuid4())
size = 1000000
with open(filename, "wb") as f:
f.write(" " * size)
import os import uuid import random for dirs in os.walk("/home/zarvis"): d = dirs filename = str(uuid.uuid4()) size = random.randint(1, 100) with open(os.path.join(d, filename), "w") as f: f.write(" " * size)