#!/bin/bash

INPUT_DIR="bundles"  # Change this to your folder containing JSON files
OUTPUT_DIR="testtgs"  # Change to where you want to store gzipped files

mkdir -p "$OUTPUT_DIR"  # Ensure output folder exists

for file in "$INPUT_DIR"/*.json; do
    if [ -f "$file" ]; then
        filename=$(basename "$file")  # Get filename

        # Add key to JSON
        jq '. + {"tgs": 1}' "$file" > "$OUTPUT_DIR/$filename"

        # Gzip the modified JSON file
        gzip -c "$OUTPUT_DIR/$filename" > "$OUTPUT_DIR/$filename.tgs"

        # Remove the intermediate modified file

        echo "Processed: $file -> $OUTPUT_DIR/$filename.tgs"
    fi
done
