Codeforces-SolutionsA/Readme Generator Assets/Change name format.py
2023-12-31 16:13:23 +06:00

11 lines
493 B
Python

import os
import re
# Replace with the path to the directory containing the folders you want to rename
path_to_folders = "D:\Programming\Problems solves\Codeforces\Codes"
for folder_name in os.listdir(path_to_folders):
first_name, second_name = folder_name.split(' ', 1)
new_name = f"{first_name} - {second_name}"
new_first_name = re.sub(r'(\d+)([A-Z])', r'\1 \2', new_name)
os.rename(os.path.join(path_to_folders, folder_name), os.path.join(path_to_folders, new_first_name))