#!/usr/bin/env bash
set -euo pipefail

SRC_ROOT=~/src/dzn2.19/test/all
DEST_ROOT=$(pwd)

for dir in "$SRC_ROOT"/*/; do
    # Skip if not a directory
    [ -d "$dir" ] || continue

    subdir=$(basename "$dir")
    meta_file="$dir/META"

    if [ -f "$meta_file" ]; then
        echo "Copying META from $subdir"

        mkdir -p "$DEST_ROOT/$subdir"
        cp "$meta_file" "$DEST_ROOT/$subdir/"
    fi
done

echo "Done."
