import os gate_home = './src/static/Gate' word_home = './src/static/Word' for folder in os.listdir(gate_home): folder_path = os.path.join(gate_home, folder) for file in os.listdir(folder_path): file_path = os.path.join(folder_path, file) if '$' not in file: name = file.split('.')[0] rename_path = f'{folder_path}/$_{name}_.svg' os.rename(file_path, rename_path) for folder in os.listdir(word_home): folder_path = os.path.join(word_home, folder) for file in os.listdir(folder_path): file_path = os.path.join(folder_path, file) if '$' not in file: name = file.split('.')[0] rename_path = f'{folder_path}/${name}.svg' os.rename(file_path, rename_path)