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

View file

@ -1,10 +1,16 @@
#!/bin/zsh #!/bin/zsh
mydir=$(dirname "$0")
# Define the absolute path to the prep script # Define the absolute path to the prep script
PREP_SCRIPT="$(cd "$(dirname "$0")" && pwd)/prep 1 font.sh" PREP_SCRIPT="$(cd "$(dirname "$0")" && pwd)/prep 1 font.sh"
#activate python environment
source "$(cd "$(dirname "$0")" && pwd)/.env/bin/activate"
#move orphans before we do anything else
python $mydir/orphans.py
# Check if the prep script exists # Check if the prep script exists
if [[ ! -f "$PREP_SCRIPT" ]]; then if [[ ! -f "$PREP_SCRIPT" ]]; then
echo "Prep script not found: $PREP_SCRIPT" echo "Prep script not found: $PREP_SCRIPT"

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()

View file

@ -1,5 +1,10 @@
#! /bin/zsh #! /bin/zsh
#uncomment if you want to delete all .setup_complete files and process everything
#find . -name '*.setup_complete' -type f -delete
#if file name .setup_complete exists, exit #if file name .setup_complete exists, exit
if [ -f .setup_complete ]; then if [ -f .setup_complete ]; then
echo "This folder has already been prepped. Please delete the .setup_complete file if you would like to run this script again." echo "This folder has already been prepped. Please delete the .setup_complete file if you would like to run this script again."
@ -41,4 +46,5 @@ find . -name '*.otf' -type f -exec mv {} OTF \;
# Recurse through all folders and subfolders and delete all empty folders # Recurse through all folders and subfolders and delete all empty folders
find . -type d -empty -delete find . -type d -empty -delete
# create a .setup_complete file to indicate that the folder has been prepped
touch .setup_complete touch .setup_complete