From a829efc23aa9e495f4e032ae502a4418bbe7780e Mon Sep 17 00:00:00 2001 From: Matt Troutman Date: Wed, 2 Oct 2024 15:15:07 -0500 Subject: [PATCH] no message --- .fontfoldercleanup/font_folder_cleanup.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/.fontfoldercleanup/font_folder_cleanup.py b/.fontfoldercleanup/font_folder_cleanup.py index 5d0b92e..fc15880 100644 --- a/.fontfoldercleanup/font_folder_cleanup.py +++ b/.fontfoldercleanup/font_folder_cleanup.py @@ -220,13 +220,14 @@ def remove_setup_complete_files(root_path=font_location): 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 + for root, dirs, files in os.walk(root_path, topdown=False): + for dir in dirs: + dir_path = os.path.join(root, dir) if ' ' in dir: new_dir = dir.replace(' ', '-') - new_dir_path = os.path.join(root_path, new_dir) + #lowercase the new directory name + new_dir = new_dir.lower() + new_dir_path = os.path.join(root, new_dir) os.rename(dir_path, new_dir_path) print(f"Renamed directory: {dir_path} -> {new_dir_path}") @@ -243,6 +244,7 @@ def prepend_folder_name_to_font_dash(root_path=font_location): print(f"Renamed directory: {dir_path} -> {new_dir_path}") + def lowercase_and_dash_file_names(root_path=font_location): for root, dirs, files in os.walk(root_path): for file in files: