feat: add dataset preprocess script
Browse files
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}")
|