#!/bin/bash
: ${destdir:=$HOME/amiga/games}
mkdir -p "$destdir"
for zip; do
	game="${zip%.*}"
	echo "$game	"
	if [ -z "$game" ]; then
		echo "bad zip name: $zip"
		exit 1
	fi
	dir="$destdir/$game"
	if [ -e "$dir" ]; then
		echo "game directory already exists, skipping: $dir"
		continue
	fi
	if unzip -qq -d "$dir" -x "$zip" 2>/dev/null; then
		echo "ok"
	else
		rm -rf "$dir"
		echo "failed"
	fi
done
