#!/bin/bash
# Set the base directory
base_dir="/home/howard/tickets"
# Loop through each subdirectory in the base directory
for subdir in "$base_dir"/*/; do
# Get the name of the subdirectory
subdir_name=$(basename "$subdir")
# Find all files in the subdirectory that start with "investigation"
investigation_files=("$subdir"/investigation*)
# If there are any files, create a tarball with the subdirectory name
if [ "${#investigation_files[@]}" -gt 0 ]; then
tar -czf "$subdir_name"_investigation.tar.gz "${investigation_files[@]}"
echo "Created tarball: $subdir_name"_investigation.tar.gz
else
echo "No investigation files found in $subdir_name"
fi
done