First post, by Guest
Hey guys, a while back I wrote a W2k/XP batch file that scans a folder and its subfolders for .EXE, .COM and .BAT files, then for each file it finds it creates a batch file that launches that file using DOSBox. I find it very handy and I hope you do too. I especially hope a real programmer improves it or, even better, integrates the idea into future DOSBox releases.
You will probably need to edit the variables to reflect your system: dosbox location, source folder you want it to scan, destination where you want the batch files created, and DOSBox command line switches.
Use at your own risk and feel free to do whatever you want with this.
@ECHO OFF
SETLOCAL
REM DOSBox Shortcutter for Windows 2000 or XP
REM Version 0.1
REM by DPainter (shift838@yahoo.com)
REM
REM Use at your own risk!
REM Change these variables to reflect your system setup.
SET dosbox=C:\DOSBOX
SET source=C:\DOSBOX\GAMES
SET destination=C:\DOSBOX\RUN
SET switches=-exit
CLS
ECHO DOSbox Shortcutter v0.1 by DPainter
ECHO.
IF NOT EXIST %destination%\NUL GOTO error
IF NOT EXIST %dosbox%\NUL GOTO error
:begin
for /f "tokens=*" %%c in ('cd') do set homedir=%%c
cd %source%
for /f "tokens=* delims=\" %%a in ('dir /s *.EXE *.BAT *.COM /b') do (
SET FullPath=%%a
SET ShortName=%%~dpa
SET filename=%%~nxa
CALL :process
)
GOTO :end
:process
REM File names to skip. Add others if you find them.
IF /i "%filename%"=="DOS4GW.EXE" GOTO :SKIP
IF /i "%filename%"=="ADLIB.COM" GOTO :SKIP
CD %ShortName%
FOR /f "tokens=* delims=\" %%d in ('cd') do set foldername=%%~nd
IF EXIST %destination%\%foldername%__%filename%.bat GOTO :EXISTS
ECHO Creating %foldername%_%filename%.bat in %destination%
ECHO %dosbox%\dosbox.exe %switches% "%FullPath%" > "%destination%\%foldername%__%filename%.bat"
GOTO :end
:EXISTS
ECHO !! Already exists '%foldername%__%filename%.bat'
GOTO :end
:SKIP
ECHO !! Skipping %FullPath%...
GOTO :END
:error
ECHO.
ECHO There was an error. Ensure your variables are correct.
ECHO.
GOTO :eof
:end
SET dosbox=
SET source=
SET destination=
SET switches=
CD %HOMEDIR%
ENDLOCAL
goto :eof