#!/bin/bash
new=$1
title=$new
skel="zz_Skeleton"
if [ ! -d "$new" ]; then
	echo "New $new from $skel"
	if [[ $new == *"_"* ]]; then
		pos=`expr index $new _`
		title=${new:$pos}
	fi
	cp -r $skel $new
	mv "$new/zz_Skeleton.toc" "$new/$new.toc"
	sed -i "s/Title: Skeleton/Title: $title/" "$new/$new.toc"
	sed -i "s/SavedVariables: zz_SkeletonDB/SavedVariables: ${new}DB/" "$new/$new.toc"
	sed -i "s/${skel}/${new}/" "$new/init.lua"
else
	echo "$new exists skipped."
fi
