updated structure a bit.
This commit is contained in:
parent
46156f7bdd
commit
358e94cde7
7 changed files with 61 additions and 15 deletions
|
|
@ -3,6 +3,8 @@ import time
|
||||||
from fileinput import filename
|
from fileinput import filename
|
||||||
repo_location = '/Users/fishy/custom_fonts'
|
repo_location = '/Users/fishy/custom_fonts'
|
||||||
|
|
||||||
|
os.system(f"cd ")
|
||||||
|
|
||||||
font_location = f'{repo_location}/font_files'
|
font_location = f'{repo_location}/font_files'
|
||||||
|
|
||||||
bad_phrases = [' Free',
|
bad_phrases = [' Free',
|
||||||
|
|
|
||||||
51
.fontfoldercleanup/iterate.py
Normal file
51
.fontfoldercleanup/iterate.py
Normal file
|
|
@ -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()
|
||||||
|
|
@ -21,8 +21,8 @@ fi
|
||||||
#recursively find all .zip files and unzip them
|
#recursively find all .zip files and unzip them
|
||||||
find . -name '*.zip' -exec unzip {} \;
|
find . -name '*.zip' -exec unzip {} \;
|
||||||
|
|
||||||
# Make OTF and TTF folders if they don't exist
|
# Make otf and ttf folders if they don't exist
|
||||||
mkdir -p OTF TTF "other files"
|
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
|
# 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" \;
|
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 '*.cfg' -type f -delete
|
||||||
find . -name '*.zip' -type f -delete
|
find . -name '*.zip' -type f -delete
|
||||||
|
|
||||||
# Recurse through all folders and subfolders and move all .ttf files into the TTF folder
|
# Recurse through all folders and subfolders and move all .ttf files into the ttf folder
|
||||||
find . -name '*.ttf' -type f -exec mv {} TTF \;
|
find . -name '*.ttf' -type f -exec mv {} ttf \;
|
||||||
# Recurse through all folders and subfolders and move all .ttc files into the TTF folder
|
# Recurse through all folders and subfolders and move all .ttc files into the ttf folder
|
||||||
find . -name '*.ttc' -type f -exec mv {} TTF \;
|
find . -name '*.ttc' -type f -exec mv {} ttf \;
|
||||||
# Recurse through all folders and subfolders and move all .otf files into the OTF folder
|
# Recurse through all folders and subfolders and move all .otf files into the otf folder
|
||||||
find . -name '*.otf' -type f -exec mv {} OTF \;
|
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
|
||||||
|
|
@ -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
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue