Skip to content

Instantly share code, notes, and snippets.

@danlester
Created December 6, 2021 16:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danlester/8fd8de628abf56608a7fdc53a27693ce to your computer and use it in GitHub Desktop.
Save danlester/8fd8de628abf56608a7fdc53a27693ce to your computer and use it in GitHub Desktop.
Generate a lot of files for testing
import os
from pathlib import Path
jupyter_user = os.environ['JUPYTERHUB_USER']
def make_files(depth, breadth, start_folder, key, max_depth=3):
print(f"Make Files at depth {depth}")
for i in range(0,breadth):
with Path(start_folder, f"testfile_{key}_{depth}_{i}.txt").open("wt") as f:
f.write("Here is the file.")
if depth < max_depth:
newfolder = Path(start_folder, f"folder_test_{key}_{depth}_{i}")
newfolder.mkdir(exist_ok=True)
make_files(depth+1, breadth, newfolder, key, max_depth)
make_files(0, 10, "/home/jovyan", f"{jupyter_user}", 2)
make_files(0, 10, "/home/shared/accounting", f"{jupyter_user}_admin")
make_files(0, 4, "/home/shared/users", f"{jupyter_user}_users", 5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment