setup scripts

This commit is contained in:
Matt Troutman 2024-09-27 12:17:58 -05:00
parent e1194a4877
commit 08cd03bf8f
No known key found for this signature in database
3 changed files with 34 additions and 1 deletions

21
orphans.py Normal file
View file

@ -0,0 +1,21 @@
import os
# Define the absolute path to the font_files directory
FONT_FILES_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'font_files')
# find all files that are otfs or ttfs at the root of the font_files directory
def handle_orphans(font_files_dir=FONT_FILES_DIR):
FONT_FILES = [file for file in os.listdir(FONT_FILES_DIR) if file.endswith('.otf') or file.endswith('.ttf')]
print(FONT_FILES)
for file in FONT_FILES:
#create a directory for the file
new_dir_path = os.path.join(FONT_FILES_DIR, file.split('.')[0])
if not os.path.exists(new_dir_path):
os.mkdir(new_dir_path)
print(f"Created directory: {new_dir_path}")
#move the file to the directory
new_file_path = os.path.join(new_dir_path, file)
os.rename(os.path.join(FONT_FILES_DIR, file), new_file_path)
print(f"Moved {file} to {new_file_path}")
if __name__ == '__main__':
handle_orphans()