XX=if %1 looks like c:\dir 1\scummvm1\dir 2\CurrentDir\!!AA.BAT is a problem, so i need to check if currentDir has a scummvm string in it
YY=if %1 looks like c:\dir 1\dir 2\CurrentDir - scummvm1\BB.BAT is a scummvm file because i named all their current dirs with a word scummvm in them.
ZZ=if %1 looks like c:\dir 1\dir 2\CurrentDir\!!CC.BAT is a dosbox file. because i named the 1st file with "!!" in it.
AA= works except for the case of XX
Code: Select all
FOR /F "Tokens=*" %%V IN ('ECHO "%~1" ^|FIND "scumm" /I /C') DO SET C1=%%V
FOR /F "Tokens=*" %%V IN ('DIR "%~1\!!*.BAT" /A-D /ON /B') DO SET F1=%%V
IF /I NOT "%C1%"=="0" GOTO :SCUMMVM
IF /I NOT "%F1%"=="" GOTO :BOX
BB= doesnt work
Code: Select all
FOR %%V IN ("%~dp0.") DO SET "CD1=%%~nxV"
ECHO "%CD1%"
SET "Z2=%~p0"
SET "Z2=%Z2:~0,-1%"
FOR %%V IN ("%Z2%") DO SET "CD1=%%~nxV"
ECHO "%CD1%"
FOR %%V IN ("%CD%") DO SET "CD1=%%~nxV"
ECHO "%CD1%"
FOR /F "Tokens=*" %%V IN ('ECHO "%CD1%" ^|FIND "scumm" /I /C') DO SET C1=%%V
FOR /F "Tokens=*" %%V IN ('DIR "%~1\!!*.BAT" /A-D /ON /B') DO SET F1=%%V
IF /I NOT "%C1%"=="0" GOTO :SCUMMVM
IF /I NOT "%F1%"=="" GOTO :BOX
i dont know why BB doesnt work, maybe CD1 is acting like a filename instead of a current dir name. when i tested all 3 CD1's, they all reported current dirs correctly.
you can make AA= more stable if you wish, i didnt quote them at the end, but i tried "F1=%%V" "F1=%%~V". C1=%%V was a best choce i ran out of energy to check \ and "" more.