Here's a bash script that will loop through all the seasons and invoke your Python script with the appropriate filenames. I'll make it clear and add some feedback so you can see what's happening.
Save this as run_seasons.sh:
#!/bin/bash
# Define start and end years
start_year=1997
end_year=2024
echo "🚀 Starting to process all seasons from ${start_year}-$(($start_year+1)) to ${end_year}-$(($end_year+1))"
echo "----------------------------------------"
# Loop through the years
for year in $(seq $start_year $end_year); do
# Calculate the season string
season="${year}-$((year+1))"
echo "⏳ Processing season: $season"
# Define the filenames for this season
table_file="table_${season}.txt"
schedule_file="schedule_${season}.txt"
c_output_file="C_output_${season}.txt"
excel_output_file="Excel_output_${season}.txt"
# Print the command being executed
echo " Executing Python script for $season..."
# Run the Python script with the appropriate parameters
python script.py "$table_file" "$schedule_file" "$c_output_file" 20 "$excel_output_file"
# Check if the command was successful
if [ $? -eq 0 ]; then
echo " ✅ Successfully processed season $season"
else
echo " ❌ Error processing season $season"
fi
echo "----------------------------------------"
done
echo "🎉 All seasons have been processed!"
To use this script:
- Save it as
run_seasons.sh
- Make it executable (in Cygwin):
chmod +x run_seasons.sh
- Run it:
./run_seasons.sh
The script will:
- Loop through all seasons from 1997-1998 to 2024-2025
- Generate the appropriate filenames for each season
- Run your Python script with those filenames
- Provide feedback about what it's doing and whether each season was processed successfully
You'll see output like this:
🚀 Starting to process all seasons from 1997-1998 to 2024-2025
----------------------------------------
⏳ Processing season: 1997-1998
Executing Python script for 1997-1998...
✅ Successfully processed season 1997-1998
----------------------------------------
⏳ Processing season: 1998-1999
Executing Python script for 1998-1999...
✅ Successfully processed season 1998-1999
----------------------------------------
[and so on...]
If you want to test it first, you can add echo before the Python command to see what commands would be executed without actually running them. Just modify this line:
# Add echo to test without executing
echo python script.py "$table_file" "$schedule_file" "$c_output_file" 20 "$excel_output_file"
Also, if you need to change the Python interpreter (for example, if you're using Python 3 specifically), you can modify the command to use python3 instead of python.
Would you like me to modify anything about this script to better suit your needs?