-
Notifications
You must be signed in to change notification settings - Fork 0
/
generator.py
31 lines (26 loc) · 1.05 KB
/
generator.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import sys
import random
import string
from pathlib import Path
if len(sys.argv)<4:
sys.exit("File requires <# of files to generate> <# chars for files' name> <# of chars to populate in each file> ");
def generateFiles():
alpha = string.ascii_letters+string.digits;
data = alpha+string.whitespace;
for num in range(int(sys.argv[1])):
'''Random letter or digit is being created as many times as range has
so I pick random character will be created in list ex[a,c,e,r,g]
then i join the characters with the string '' to make it one word.'''
#file name + .txt
filename = ''.join(random.choice(alpha) for num in range( int(sys.argv[2]) ) )+".txt";
#path of file to accomedate any system
file_path = Path("./"+filename);
#each file created wi;l get populated with random data
with open(filename,"w")as file:
#populate the data
filedata=''.join(random.choice(data)for i in range( int(sys.argv[3]) ) );
#write the data in the file
file.write(filedata);
print(filename+" created and populated!")
#print(filedata);
generateFiles()