diff --git a/create repos for fonts.py b/.fontfoldercleanup/create repos for fonts.py similarity index 100% rename from create repos for fonts.py rename to .fontfoldercleanup/create repos for fonts.py diff --git a/.fontfoldercleanup/font_folder_cleanup.py b/.fontfoldercleanup/font_folder_cleanup.py index 8e1fee1..aecf88b 100644 --- a/.fontfoldercleanup/font_folder_cleanup.py +++ b/.fontfoldercleanup/font_folder_cleanup.py @@ -3,6 +3,8 @@ import time from fileinput import filename repo_location = '/Users/fishy/custom_fonts' +os.system(f"cd ") + font_location = f'{repo_location}/font_files' bad_phrases = [' Free', diff --git a/.fontfoldercleanup/iterate.py b/.fontfoldercleanup/iterate.py new file mode 100644 index 0000000..d395164 --- /dev/null +++ b/.fontfoldercleanup/iterate.py @@ -0,0 +1,51 @@ +import os +import subprocess +import sys + +def main(): + mydir = os.path.dirname(__file__) + + # Define the absolute path to the prep script + prep_script = os.path.join(mydir, 'prep 1 font.sh') + + # Activate python environment + env_activate = os.path.join(mydir, '.env/bin/activate') + subprocess.run(['source', env_activate], shell=True, check=True) + + # Move orphans before we do anything else + orphans_script = os.path.join(mydir, 'orphans.py') + subprocess.run(['python3', orphans_script], check=True) + + # Check if the prep script exists + if not os.path.isfile(prep_script): + print(f"Prep script not found: {prep_script}") + sys.exit(1) + + # Ensure the prep script is executable + os.chmod(prep_script, 0o755) + + # Check if the prep script is executable + if not os.access(prep_script, os.X_OK): + print(f"Prep script not executable: {prep_script}") + sys.exit(1) + + # Define the absolute path to the font_files directory + font_files_dir = os.path.join(mydir, 'font_files') + + # Check if the font_files directory exists + if not os.path.isdir(font_files_dir): + print(f"font_files directory not found: {font_files_dir}") + sys.exit(1) + + # Iterate over each folder in font_files + for folder in os.listdir(font_files_dir): + folder_path = os.path.join(font_files_dir, folder) + if os.path.isdir(folder_path): + os.chdir(folder_path) + subprocess.run(['zsh', prep_script], check=True) + os.chdir('..') + else: + print(f"No such directory: {folder}") + +if __name__ == '__main__': + main() \ No newline at end of file diff --git a/iterate.sh b/.fontfoldercleanup/iterate.sh similarity index 100% rename from iterate.sh rename to .fontfoldercleanup/iterate.sh diff --git a/orphans.py b/.fontfoldercleanup/orphans.py similarity index 100% rename from orphans.py rename to .fontfoldercleanup/orphans.py diff --git a/prep 1 font.sh b/.fontfoldercleanup/prep 1 font.sh similarity index 84% rename from prep 1 font.sh rename to .fontfoldercleanup/prep 1 font.sh index 180ac28..f57f2a0 100755 --- a/prep 1 font.sh +++ b/.fontfoldercleanup/prep 1 font.sh @@ -21,8 +21,8 @@ fi #recursively find all .zip files and unzip them find . -name '*.zip' -exec unzip {} \; -# Make OTF and TTF folders if they don't exist -mkdir -p OTF TTF "other files" +# Make otf and ttf folders if they don't exist +mkdir -p otf ttf "other files" # Recurse through all folders and subfolders and move files that are not .ttf or .otf into the "other files" folder find . -type f -exec mv {} "other files" \; @@ -35,12 +35,12 @@ find . -name '*.ofm' -type f -delete find . -name '*.cfg' -type f -delete find . -name '*.zip' -type f -delete -# Recurse through all folders and subfolders and move all .ttf files into the TTF folder -find . -name '*.ttf' -type f -exec mv {} TTF \; -# Recurse through all folders and subfolders and move all .ttc files into the TTF folder -find . -name '*.ttc' -type f -exec mv {} TTF \; -# Recurse through all folders and subfolders and move all .otf files into the OTF folder -find . -name '*.otf' -type f -exec mv {} OTF \; +# Recurse through all folders and subfolders and move all .ttf files into the ttf folder +find . -name '*.ttf' -type f -exec mv {} ttf \; +# Recurse through all folders and subfolders and move all .ttc files into the ttf folder +find . -name '*.ttc' -type f -exec mv {} ttf \; +# Recurse through all folders and subfolders and move all .otf files into the otf folder +find . -name '*.otf' -type f -exec mv {} otf \; # Recurse through all folders and subfolders and delete all empty folders find . -type d -empty -delete diff --git a/remove_empty_folders.sh b/remove_empty_folders.sh deleted file mode 100644 index 623e8e0..0000000 --- a/remove_empty_folders.sh +++ /dev/null @@ -1,7 +0,0 @@ -#! /bin/bash - -mydir=$(dirname "$0") -cd $mydir/font_files -find . -type d -empty -delete - -#find . -name '.setup_complete' -type f -delete \ No newline at end of file