File size: 612 Bytes
fc990e8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
from pathlib import Path
import uuid
import json

filename_mapping = {}

for filename in Path("html_files").glob("*.html"):
    unique_name = filename.stem.split("_")[2]+ "_" + uuid.uuid4().hex
    # print (filename.name , unique_name)
    filename_mapping[filename.name] = unique_name

with open("filemapping.json", "w") as js:
    js.write(json.dumps(filename_mapping))
    
for filename in Path("html_files").glob("*.html"):
    new_filename = filename_mapping[filename.name] + ".html"
    print(f"Rename {filename} to {Path("html_files")/new_filename}")
    filename.rename(Path("html_files")/new_filename)