#! /bin/bash
src_path="$1"
dest_path="$2"

. scripts/inc/assets.sh

if [ "$src_path" = "" ] || [ "$dest_path" = "" ]
then
    echo >&2 "USAGE: scripts/move-block-tex.sh <src> <dest>"
    echo >&2 ""
    echo >&2 "<src> and <dest> are paths relative to each of the block texture"
    echo >&2 "folders. Moves <src> to <dest> in all of the block texture dirs,"
    echo >&2 "i.e. within blocktex, blockbias, etc."
    exit 1
fi

for subdir in $blocktex_subdirs
do
    for ext in $blocktex_ext
    do
        this_src="assets/$subdir/$src_path.$ext"
        this_dest="assets/$subdir/$dest_path.$ext"

        if [ -e "$this_src" ]
        then
            echo "Moving: '$this_src' -> '$this_dest'"
            mkdir -p "`dirname $this_dest`" || exit 1
            mv "$this_src" "$this_dest" || exit 1
        fi
    done
done