echo off

rem -------This sets the variable ext to equal the extension of the ROM
set ext=%~x1
rem -------This sets the variable tyu to equal the path and name of the ROM so that it can be manipulated
set tyu=%1
rem -------This removes the last three characters.  MameWah sends the * as an extension (as set in ME.ini)
rem --------so we take off the ending quote, the star and the decimal for good measure
set one=%tyu:~0,-3%

rem -------This determines which program to launch depending on the file extension of the ROM
if /i %ext% EQU .zip goto MAME
if /i %ext% EQU .smc goto SNES-SMC
if /i %ext% EQU .swc goto SNES-SWC
if /i %ext% EQU .fig goto SNES-FIG
if /i %ext% EQU .nes goto NES
if /i %ext% EQU .v64 goto N64
if /i %ext% EQU .LNK goto LNK

rem -------This just lets you know if you need to set up a new IF statement for a file extension
echo %ext%
echo extension not found
pause
goto end 

rem -------The following code launches a program determined above by the file extension
:MAME
cd C:\mame
mame %one%.bat"
goto end

:SNES-SWC
cd C:\Documents and Settings\barrier\Desktop\misc MAME\EMUs\SNES
zsnesw.exe %one%.swc"
goto end

:SNES-SMC
cd C:\Documents and Settings\barrier\Desktop\misc MAME\EMUs\SNES
zsnesw.exe %one%.smc"
goto end

:SNES-FIG
cd C:\Documents and Settings\barrier\Desktop\misc MAME\EMUs\SNES
zsnesw.exe %one%.fig"
goto end

:NES
cd C:\Documents and Settings\barrier\Desktop\misc MAME\EMUs\NES
fceu.exe %one%.nes"
goto end

:N64
cd C:\Program Files\Project64 v1.5
rem -------PROJECT64 didn't like the quotation marks, so this removes the beginning one
set n64t=%one:~1%
project64.exe %n64t%.v64
goto end

:LNK
%one%.lnk
goto end

:end