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 -w switch performs Wad Archive game search.
  • Generated script -g switch Googles game.

  • Generated script -c switch opens GZDoom command line parameters help.

 

SCRIPTS

 

HELP

 

dbsg.bat

 

Spoiler

DESCRIPTION

Command-line GZDoom Windows batch script generator v.1.7

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

Generated script can accept user parameters.

Project site: http://dbsg.sf.net

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 '-w' switch performs Wad Archive game search.
* Generated script '-g' switch Googles game.
* Generated script '-c' switch opens GZDoom command line parameters help.

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           GZDoom executable. 'gzdoom.exe' is default.
doomConfig     GZDoom user configuration. 'gzdoom-%USERNAME%.ini' is default.
wad            main wad. 'doom2.wad' is default.
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.
Any GZDoom parameters are accepted as script parameters if no script specific switches are specified.

COMMAND LINE

Switches are mutually exclusive, only one at a time:

-w             Wad Archive game search.
-g             Google game search.
-c             open GZDoom command line help.

KNOWN ISSUES

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

 

 

CONFIG

 

dbsg-config.bat

 

Spoiler

:: GZDoom executable.
::set doom=my-doom.exe

:: Existing GZDoom user config at GZDoom dir.
::set doomConfig=my-doom-config.ini

:: Main wad.
::set wad=doom2.wad

:: DEH
::set deh=my.deh

:: BEX
::set bex=my.bex

:: Saves dir.
::set savedir=my-savedir

:: Screenshots dir.
::set shortdir=my-shortdir

:: Mods.
::set mods=target-spy-v1.14.pk3

:: Any GZDoom parameters.
:: https://zdoom.org/wiki/Command_line_parameters
::set params=-fast

:: Load last save if set.
::set loadLast=1

:: Save extension.
::set saveExt=zds

:: Script prefix. "" for empty.
::set scriptPrefix=""

:: Update script launch time if set.
set updateLaunch=1

 

 

GENERATED SCRIPTS EXAMPLES

 

dbsg-doom2.bat

 

Spoiler

@echo off

:: Generated by GZDoom Windows batch script generator 1.7
:: http://dbsg.sf.net

:: Run script to launch the game.
:: Any GZDoom parameters are accepted as script parameters if no script specific switches are specified.

:: Command line switches are mutually exclusive, only one at a time:
:: -w  Wad Archive game search.
:: -g  Google game search.
:: -c  open GZDoom command line parameters help.

:: 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

:: Process command line.
call :processCommandLine "%~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

:: GZDoom 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 GZDoom 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 GZDoom 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

:processCommandLine
setlocal
set what=%~n2
if "%what%"=="" set what=%~n3
if /i "%~1"=="-w" echo Searching Wad Archive for '%what%'... & start "Searching Wad Archive for '%what%'..." /b "https://www.wad-archive.com/search?q=%what%" & exit /b 1
if /i "%~1"=="-g" echo Googling '%what%'... & start "Googling '%what%'..." /b "https://google.com/search?q=%what% doom wad OR pk3 OR ipk3 OR zip OR 7z" & exit /b 1
if /i "%~1"=="-c" echo Opening GZDoom command line parameters help... & start "Opening GZDoom command line parameters help..." /b "https://zdoom.org/wiki/Command_line_parameters" & 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.7
:: http://dbsg.sf.net

:: Run script to launch the game.
:: Any GZDoom parameters are accepted as script parameters if no script specific switches are specified.

:: Command line switches are mutually exclusive, only one at a time:
:: -w  Wad Archive game search.
:: -g  Google game search.
:: -c  open GZDoom command line parameters help.

:: 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=1
set updateLaunch=1

set saveExt=zds

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

:: Process command line.
call :processCommandLine "%~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

:: GZDoom 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 GZDoom 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 GZDoom 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

:processCommandLine
setlocal
set what=%~n2
if "%what%"=="" set what=%~n3
if /i "%~1"=="-w" echo Searching Wad Archive for '%what%'... & start "Searching Wad Archive for '%what%'..." /b "https://www.wad-archive.com/search?q=%what%" & exit /b 1
if /i "%~1"=="-g" echo Googling '%what%'... & start "Googling '%what%'..." /b "https://google.com/search?q=%what% doom wad OR pk3 OR ipk3 OR zip OR 7z" & exit /b 1
if /i "%~1"=="-c" echo Opening GZDoom command line parameters help... & start "Opening GZDoom command line parameters help..." /b "https://zdoom.org/wiki/Command_line_parameters" & 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           GZDoom executable. 'gzdoom.exe' is default.
doomConfig     GZDoom 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. Any GZDoom parameters are accepted as script parameters if no script specific switches are specified.

 

COMMAND LINE

 

Switches are mutually exclusive, only one at a time:

 

-w             Wad Archive game search.
-g             Google game search.
-c             open GZDoom command line help.

 

KNOWN ISSUES

 

Names with spaces, percent and culture-specific characters may 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
×