diff --git a/iterate.sh b/iterate.sh index 4f4cb93..d44f071 100644 --- a/iterate.sh +++ b/iterate.sh @@ -1,10 +1,16 @@ #!/bin/zsh - +mydir=$(dirname "$0") # Define the absolute path to the prep script 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 if [[ ! -f "$PREP_SCRIPT" ]]; then echo "Prep script not found: $PREP_SCRIPT" diff --git a/orphans.py b/orphans.py new file mode 100644 index 0000000..05565b1 --- /dev/null +++ b/orphans.py @@ -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() \ No newline at end of file diff --git a/prep 1 font.sh b/prep 1 font.sh index cc6776e..2cf2512 100755 --- a/prep 1 font.sh +++ b/prep 1 font.sh @@ -1,5 +1,10 @@ #! /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 [ -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." @@ -41,4 +46,5 @@ find . -name '*.otf' -type f -exec mv {} OTF \; # Recurse through all folders and subfolders and delete all empty folders find . -type d -empty -delete +# create a .setup_complete file to indicate that the folder has been prepped touch .setup_complete \ No newline at end of file