no message

This commit is contained in:
Matt Troutman 2024-10-02 15:03:29 -05:00
parent 43133c6347
commit b7777b024a
No known key found for this signature in database

View file

@ -135,7 +135,7 @@ def collect_orphaned_fonts(path=font_location):
def lowercase_all_the_folders(root_path=font_location):
"""
Lowercases all the folders in the root path, except those starting with a period.
Lowercases all the folders recursively in the root_path.
Args:
root_path (str): The path to the directory to be checked and cleaned.
@ -143,15 +143,14 @@ def lowercase_all_the_folders(root_path=font_location):
Returns:
None
"""
for dir in os.listdir(root_path):
dir_path = os.path.join(root_path, dir)
if os.path.isdir(dir_path):
if dir.startswith('.'):
continue
new_dir_path = os.path.join(root_path, dir.lower())
for root, dirs, files in os.walk(root_path):
for dir in dirs:
dir_path = os.path.join(root, dir)
new_dir_path = os.path.join(root, dir.lower())
os.rename(dir_path, new_dir_path)
print(f"Renamed directory: {dir_path} -> {new_dir_path}")
def add_font_folders_to_each(root_path=font_location):
for dir in os.listdir(root_path):
dir_path = os.path.join(root_path, dir)
@ -243,25 +242,29 @@ def prepend_folder_name_to_font_dash(root_path=font_location):
os.rename(dir_path, new_dir_path)
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:
file_path = os.path.join(root, file)
new_file_path = os.path.join(root, file.lower())
#let's also remove spaces in the file names
# Remove spaces in the file names
new_file_path = new_file_path.replace(' ', '-')
os.rename(file_path, new_file_path)
print(f"Renamed file: {file_path} -> {new_file_path}")
# Check if the file exists before renaming
if os.path.exists(file_path):
os.rename(file_path, new_file_path)
print(f"Renamed file: {file_path} -> {new_file_path}")
else:
print(f"File not found: {file_path}")
if __name__ == '__main__':
remove_ds_store_files()
remove_empty_folders()
remove_bad_phrases()
collect_orphaned_fonts()
remove_bad_phrases()
lowercase_all_the_folders()
# add_font_folders_to_each()
remove_spaces_in_dir_names()
lowercase_and_dash_file_names()
# lowercase_and_dash_file_names()
prepend_folder_name_to_font_dash()
remove_ds_store_files()
remove_empty_folders()