#!/bin/bash

# Define path to the trainers file in the current directory
TRAINERS_FILE="./personal-trainers.txt"

# Loop through each file in the response subdirectory
for file in ./response/*; do
    # Get just the filename without the path
    filename=$(basename "$file")
    
    # Flag to track if we found a match
    found_match=false
    
    # Check each line in the personal trainers file
    while read -r trainer; do
        # Skip empty lines
        if [ -z "$trainer" ]; then
            continue
        fi
        
        # Check if filename starts with the trainer name
        if [[ "$filename" == "$trainer"* ]]; then
            # Run with the personal-training flag
            python3 sort.py "$file" --personal-training
            found_match=true
            break
        fi
    done < "$TRAINERS_FILE"
    
    # If no match was found, run the standard command
    if [ "$found_match" = false ]; then
        python3 sort.py "$file"
    fi
done
