#!/bin/bash

# Get the paths of all subfolders in the current directory
folders=$(find . -mindepth 1 -maxdepth 1 -type d)

for folder in $folders; do
    # Find files in the subfolder that do not end with .tar.gz
    files=$(find "$folder" -type f ! -name "*.tar.gz")

    for file in $files; do
        # Compress files into .tar.gz format
        tar -zcvf "${file}.tar.gz" -C "$(dirname "$file")" "$(basename "$file")"
        echo "Compression completed: ${file}.tar.gz"
    done
done

echo "All files compressed!"

