Skip to content

Instantly share code, notes, and snippets.

Last active October 26, 2022 06:17
What would you like to do?
test write files
import argparse
import pathlib
import os
if __name__ == "__main__":
parser = argparse.ArgumentParser(description='create directories and write files')
parser.add_argument('target', type=pathlib.Path)
parser.add_argument('--num-directories', type=int, default=1000)
parser.add_argument('--num-total-files', type=int, default=1281167)
parser.add_argument('--file-size', type=int, default=100)
args = parser.parse_args()
os.makedirs(, exist_ok=True)
for i in range(args.num_directories):
directory_path = / f'{i:04d}'
num_files = args.num_total_files // args.num_directories + int(i < args.num_total_files % args.num_directories)
for j in range(num_files):
file_path = directory_path / f'{j:08d}'
with open(file_path, 'wb') as f:
f.write(b'0123456789abcdef' * 64 * args.file_size)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment