#!/bin/bash

# Directory containing the files to upload
DATA_DIR="datafiles"

# Path to the transfer_to_minio.sh script
TRANSFER_SCRIPT="./transfer_to_minio.sh"

# Check if the data directory exists
if [ ! -d "$DATA_DIR" ]; then
    echo "Error: Directory $DATA_DIR not found."
    exit 1
fi

# Check if the transfer script exists
if [ ! -f "$TRANSFER_SCRIPT" ]; then
    echo "Error: Transfer script $TRANSFER_SCRIPT not found."
    exit 1
fi

# Loop through all files in the data directory
for file in "$DATA_DIR"/*; do
    if [ -f "$file" ]; then
        echo "Uploading file: $file"
        bash "$TRANSFER_SCRIPT" "$file"
        echo "-----------------------------------"
    fi
done

echo "All files have been processed."