Cleaned up the sql batch installer

Cleaned up the sql batch installer so that it makes use of 'dir' a little more wisely. Also fixed the issues with re-installing of some databases multiple times.