-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutil.py
More file actions
29 lines (20 loc) · 773 Bytes
/
util.py
File metadata and controls
29 lines (20 loc) · 773 Bytes
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
import random
import string
import os
def generate_filecode():
# Generate 3 random letters
letters = random.choices(string.ascii_uppercase, k=3)
# Generate 3 random digits
digits = random.choices(string.digits, k=3)
# Combine them alternately
result = ''.join(l + d for l, d in zip(letters, digits))
return result
def find_my_file(directory, search_string):
# Loop through the files in the directory
for filename in os.listdir(directory):
# Check if the search string is in the filename
if search_string in filename:
temp = filename.split("___"+search_string+"___")
ofilename = "".join(temp)
return directory + "/" + filename, ofilename
return None, None