#!/bin/bash
#the gnuboy executable should be named "gnub" and should NOT have a .gpe
# file extension (as it would get erased by this next line)
rm *.gpe
# work on all gb/gbc files in the roms/ directory
for i in roms/*\.gb*
do
    # generate the name of the .gpe script for this rom
    tmp=${i%.*}.gpe
    sn=${tmp#roms/}
    # write out the contents of the new .gpe script
    echo ./gnub \"$i\" > "$sn"
    echo cd /usr/gp2x >> "$sn"
    echo exec ./gp2xmenu >> "$sn"
done