From 522f6154d0fa68bfc143fe56202c5e5b1f899690 Mon Sep 17 00:00:00 2001 From: Matt Troutman Date: Wed, 2 Oct 2024 13:45:04 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=A4=9E=F0=9F=8F=BCMaybe=20closer=3F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .fontfoldercleanup/cleanup.py | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) 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()