gyrojeff commited on
Commit
a2a1bfa
·
1 Parent(s): cf70bb7

feat: add dataset preprocess script

Browse files
Files changed (1) hide show
  1. dataset_filename_preprocess.py +23 -0
dataset_filename_preprocess.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+
3
+ from font_dataset.utils import get_files
4
+
5
+ directory_path = "dataset"
6
+
7
+ files = get_files(directory_path)
8
+
9
+
10
+ def clean_name(file_name: str):
11
+ return (
12
+ file_name.replace("&", "-")
13
+ .replace("@", "-")
14
+ .replace("#", "-")
15
+ .replace("$", "-")
16
+ )
17
+
18
+
19
+ for file_name in files:
20
+ new_file_name = clean_name(file_name)
21
+ if new_file_name != file_name:
22
+ os.rename(file_name, new_file_name)
23
+ print(f"Renamed {file_name} to {new_file_name}")