diff --git a/.fontfoldercleanup/cleanup.py b/.fontfoldercleanup/cleanup.py index 72cd3a5..7f57b3a 100644 --- a/.fontfoldercleanup/cleanup.py +++ b/.fontfoldercleanup/cleanup.py @@ -218,6 +218,28 @@ def remove_setup_complete_files(root_path=font_location): os.remove(file_path) print(f"Removed .setup_complete file: {file_path}") +def remove_spaces_in_dir_names(root_path=font_location): + for dir in os.listdir(root_path): + dir_path = os.path.join(root_path, dir) + if os.path.isdir(dir_path): + #If directory name contains spaces, replace them with dashes + if ' ' in dir: + new_dir = dir.replace(' ', '-') + new_dir_path = os.path.join(root_path, new_dir) + os.rename(dir_path, new_dir_path) + print(f"Renamed directory: {dir_path} -> {new_dir_path}") + + +def prepend_folder_name_to_font_dash(root_path=font_location): + for dir in os.listdir(root_path): + dir_path = os.path.join(root_path, dir) + if os.path.isdir(dir_path): + #if the directory doesn't start with 'font-', already, prepend it + if not dir.startswith('font-'): + new_dir = f'font-{dir}' + new_dir_path = os.path.join(root_path, new_dir) + os.rename(dir_path, new_dir_path) + print(f"Renamed directory: {dir_path} -> {new_dir_path}") if __name__ == '__main__': remove_ds_store_files() @@ -225,6 +247,8 @@ if __name__ == '__main__': remove_bad_phrases() collect_orphaned_fonts() lowercase_all_the_folders() - add_font_folders_to_each() + # add_font_folders_to_each() + remove_spaces_in_dir_names() + prepend_folder_name_to_font_dash() remove_ds_store_files() - remove_empty_folders() \ No newline at end of file + remove_empty_folders()