Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
i2van

Command-line GZDoom Windows batch script generator

Recommended Posts

Command-line GZDoom Windows batch script generator.

 

 

Generates editable dbsg-<game>.bat where <game> is a game file.

 

Generated script can accept user parameters.

 

Project site

 

FEATURES

 

  • Generates editable Windows batch GZDoom command-line launch script.
  • User can control generation using custom configuration.
  • Should work with any GZDoom compatible port.
  • Generated script can be easily customized.
  • Generated script is portable.
  • Generated script can accept user parameters.
  • Last saved game can be loaded on startup.
  • Generated script can set own last write time to launch time.
  • Generated script -g switch Googles game.

 

GENERATED SCRIPTS EXAMPLES

 

dbsg-doom2.bat

 

dbsg.bat -w doom2.wad

 

Spoiler

@echo off

:: Generated by GZDoom Windows batch script generator 1.6
:: https://sourceforge.net/projects/dbsg/

:: Run script to launch the game.

:: Command line:
:: -g  Google game.

:: Editable config.
set doom=gzdoom.exe

set gameDir=doom2

set game=
set wad=doom2.wad
set deh=
set bex=
set mods=
set params=
set loadLast=
set updateLaunch=1

set saveExt=zds

set doomConfig=%gameDir%\gzdoom-%USERNAME%.ini
set savedir=%gameDir%\saves
set shortdir=%gameDir%\screenshots

:: Google game.
call :google "%~1" %game% %wad% || exit /b 0

:: Update script last launch time.
if not "%updateLaunch%"=="" copy /b %0 +,, 2>&1 > nul

:: Look for a last save.
if not "%loadLast%"=="" if exist "%savedir%" echo Looking for a last save... & for /f %%i in ('dir "%savedir%\*.%saveExt%" /b /a-d /od /tw') do set recentSave=%%i

:: DooM command-line generation.
if not "%doomConfig%"=="" set doom=%doom% -config "%doomConfig%"
if not "%game%"==""       set doom=%doom% -file %game%
if not "%mods%"==""       set doom=%doom% -file %mods%
if not "%wad%"==""        set doom=%doom% -iwad "%wad%"
if not "%deh%"==""        set doom=%doom% -deh "%deh%"
if not "%bex%"==""        set doom=%doom% -bex "%bex%"
if not "%savedir%"==""    set doom=%doom% -savedir "%savedir%"
if not "%shortdir%"==""   set doom=%doom% +set screenshot_dir "%shortdir%"
if not "%params%"==""     set doom=%doom% %params%
if not "%recentSave%"=="" set doom=%doom% -loadgame "%savedir%\%recentSave%"

:: Create game dir and copy DooM user config there.
if not exist "%gameDir%"    echo Creating '%gameDir%'...    & mkdir "%gameDir%"               || goto ERROR
if not exist "%doomConfig%" echo Creating '%doomConfig%'... & call :copyConfig "%doomConfig%" || exit /b 1

echo Launching...

echo on

:: Launch DooM with command-line generated.
start "%gameDir%" /b %doom% %*

@exit /b

:copyConfig
copy "%~nx1" "%~1" || goto ERROR
exit /b

:ERROR
@echo off
echo Run failed. 1>&2
exit /b 1

:google
setlocal
set what=%~n2
if "%what%"=="" set what=%~n3
if /i "%~1"=="-g" echo Googling '%what%'... & start "Googling..." /b "https://google.com/search?q=%what% doom wad OR pk3 OR ipk3 OR zip OR 7z" & exit /b 1
endlocal
exit /b

 

 

 

dbsg-dead-air_v2.bat

 

dbsg.bat dead-air_v2.pk3

 

Spoiler

@echo off

:: Generated by GZDoom Windows batch script generator 1.6
:: https://sourceforge.net/projects/dbsg/

:: Run script to launch the game.

:: Command line:
:: -g  Google game.

:: Editable config.
set doom=gzdoom.exe

set gameDir=dead-air_v2

set game=dead-air_v2.pk3
set wad=doom2.wad
set deh=
set bex=
set mods=
set params=
set loadLast=
set updateLaunch=1

set saveExt=zds

set doomConfig=%gameDir%\gzdoom-%USERNAME%.ini
set savedir=%gameDir%\saves
set shortdir=%gameDir%\screenshots

:: Google game.
call :google "%~1" %game% %wad% || exit /b 0

:: Update script last launch time.
if not "%updateLaunch%"=="" copy /b %0 +,, 2>&1 > nul

:: Look for a last save.
if not "%loadLast%"=="" if exist "%savedir%" echo Looking for a last save... & for /f %%i in ('dir "%savedir%\*.%saveExt%" /b /a-d /od /tw') do set recentSave=%%i

:: DooM command-line generation.
if not "%doomConfig%"=="" set doom=%doom% -config "%doomConfig%"
if not "%game%"==""       set doom=%doom% -file %game%
if not "%mods%"==""       set doom=%doom% -file %mods%
if not "%wad%"==""        set doom=%doom% -iwad "%wad%"
if not "%deh%"==""        set doom=%doom% -deh "%deh%"
if not "%bex%"==""        set doom=%doom% -bex "%bex%"
if not "%savedir%"==""    set doom=%doom% -savedir "%savedir%"
if not "%shortdir%"==""   set doom=%doom% +set screenshot_dir "%shortdir%"
if not "%params%"==""     set doom=%doom% %params%
if not "%recentSave%"=="" set doom=%doom% -loadgame "%savedir%\%recentSave%"

:: Create game dir and copy DooM user config there.
if not exist "%gameDir%"    echo Creating '%gameDir%'...    & mkdir "%gameDir%"               || goto ERROR
if not exist "%doomConfig%" echo Creating '%doomConfig%'... & call :copyConfig "%doomConfig%" || exit /b 1

echo Launching...

echo on

:: Launch DooM with command-line generated.
start "%gameDir%" /b %doom% %*

@exit /b

:copyConfig
copy "%~nx1" "%~1" || goto ERROR
exit /b

:ERROR
@echo off
echo Run failed. 1>&2
exit /b 1

:google
setlocal
set what=%~n2
if "%what%"=="" set what=%~n3
if /i "%~1"=="-g" echo Googling '%what%'... & start "Googling..." /b "https://google.com/search?q=%what% doom wad OR pk3 OR ipk3 OR zip OR 7z" & exit /b 1
endlocal
exit /b

 


USAGE

 

Copy script and game files to GZDoom dir first.

dbsg.bat [-w] game [config.bat]

 

PARAMETERS

 

-w             game is standalone, e.g. doom2.wad, etc.
game           any supported game (wad, pk3, zip, etc.).
config.bat     user batch config. If not specified 'dbsg-config.bat' will be used.

 

CONFIG

 

User batch config is executed first. The following variables are supported:

 

doom           DooM executable. 'gzdoom.exe' is default.
doomConfig     DooM user configuration. 'gzdoom-%USERNAME%.ini' is default.
wad            main wad.
mods           mods (wad, pk3, zip, etc.).
deh            DEH patch.
bex            BEX patch.
savedir        savegames subdir. 'saves' is default.
shortdir       screenshots dir. 'screenshots' is default.
params         any parameters.
loadLast       load last save if set.
saveExt        save extension. 'zds' is default.
scriptPrefix   generated script prefix. '%%scriptName%%-' is default. "" for no prefix.
updateLaunch   updates last script launch time if set. set in config by default.


 

EXAMPLES

 

Edit generated script if you have any additional files.

 

  • Generate with default config:
     
    dbsg.bat dead-air_v2.pk3
  • Generate with custom config:
     
    dbsg.bat dead-air_v2.pk3 dbsg-my-config.bat
  • Specify -w flag for standalone game:
     
    dbsg.bat -w square1.pk3

 

GENERATED SCRIPT

 

Run script to launch the game.

 

COMMAND LINE

 

-g  Google game


 

KNOWN ISSUES

 

Names with spaces, percent and culture-specific characters might not be handled properly.

Edited by i2van

Share this post


Link to post

Good stuff! I really like the lean and simple approach of just creating batches to launch games :)

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×