Batch compiling question

Limpet

Newbie
Joined
Dec 27, 2004
Messages
877
Reaction score
0
This doesn't have too much to do with mapping but I'm curious anyway.

Ok, so I saw the tutorial over at Interlopers (a while back) on how to make a batchfile and compile the map outside of hammer to save some time. Now has anyone figured out how to get the newly created .bsp file and have it copied or moved to the proper maps folder?

I've been trying to get this for a couple nights now but I've had no success.

So far I have it where you can drag and drop the vmf onto the .bat it'll copy the .vmf to another folder for safe keeping, run vbsp/vvis/vrad and then end there (with a pause). What I'm looking for is how to get the name of the .vmf and store it into a variable so I can then do somthing like


Code:
set sdkmapsdir="%sourcesdk%\sourcesdk_content\hl2mp\mapsrc" 
set hl2dmmapsdir="%sourcesdk%\half-life 2 deathmatch\hl2mp\maps" 

copy %sdkmapsdir%\%examplefilename%.bsp %hl2dmmapsdir%

Whether or not thats written correctly I don't know. Again, to restate my question, does anyone know how to extract the filename without the extension of a file and store it into a variable?

I've found a couple ways but they're confusing and I don't understand them, if you want I can post them.

Thanks

(yes this is also posted in the general editing area but nobody seems to be helping there)
 
drag and drop probably won't worksince you are essentially giving the "dropped on" a paramter of "directory\filename.ext" when you need to give it filename. That's what a batch would normally do, simple use a filename no estenstion as a parameter.

In a batch file you would do something like

vbsp %1.vmf
vvis %1.bsp
vrad %1.bsp
copy "%sdkmapsdir%\%1.bsp" "%hl2dmmapsdir%"


Then you would call your batch with a comman line parameter of the filename

BATCH.bat "mymapname"

You probably should quote all filenames and directories otherwise every space will break the batchfile.
 
I have steam installed om my E drive and the maps stored on my L drive this is my batch file for the map de_fort2:

E:

cd "steam\steamapps\youremail\sourcesdk\bin"

vbsp.exe "L:\2 maps\HL2maps\css_de_fort\de_fort2.vmf"

vvis.exe "L:\2 maps\HL2maps\css_de_fort\de_fort2.vmf"

vrad.exe -smooth 85 "L:\2 maps\HL2maps\css_de_fort\de_fort2.vmf"

pause

Based on a port from the mapcore forums by a Gearbox guy, the smooth 85 is for smoothingroups if I remember right, the default value was 0.0001 or something he said :)
 
Drag and drop does work and will pass the entire path to the file when you drag and drop and use the variable %1. I've tried something similar to what you have done RoyalEF, but not that way, I will try it like that and see if it works.

Oh and the code I posted was just something I made up to kind of design what I want to happen, its not actual code I've used.

This is what I have so far and it works fine:

Code:
:: -- Set paths --
set vbsp="%sourcesdk%\bin\vbsp.exe"
set vvis="%sourcesdk%\bin\vvis.exe"
set vrad="%sourcesdk%\bin\vrad.exe"
set sourcesdkmapsdir="F:\Program Files\Valve\Steam\SteamApps\*******\sourcesdk_content\hl2mp\New"
set hl2mapsdir="F:\Program Files\Valve\Steam\SteamApps\*******\half-life 2 deathmatch\hl2mp\maps"
set backupdir="F:\Program Files\Valve\Steam\SteamApps\*******\sourcesdk_content\hl2mp\New\Batch bak"

:: -- Backup vmf --
copy %1 %backupdir%

:: -- BSP, VIS, and RAD --
%vbsp% %1
%vvis% %1
%vrad% %1

pause
 
Woohoo I finally figured it out! :imu:

And I'd thought I'd share:

Code:
@%echo off
cls

:: ----------------------------------------------------------------------------
:: -- sourcesdkmapsdir goes to where the directory where you keep your .vmfs --
:: -- hl2mapsdir goes to the hl2mp maps directory                            --
:: -- cssmapsdir goes to the CS:S maps directory                             --
:: -- backupdir goes to directory where you want your backups to go          --
:: ----------------------------------------------------------------------------
:: -- Created by Limpet "Blue" <[email protected]>                         --
:: -- The "Get Name" section modified from FILENAME.BAT by Tom Lavedas       --
:: -- <[email protected]> http://www.pressroom.com/~tglbatch/            --
:: ----------------------------------------------------------------------------

:: -- Set paths --
set vbsp="%sourcesdk%\bin\vbsp.exe"
set vvis="%sourcesdk%\bin\vvis.exe"
set vrad="%sourcesdk%\bin\vrad.exe"
set sourcesdkmapsdir=""
set hl2mapsdir=""
set cssmapsdir=""
set backupdir=""

:: -- Backup vmf --
copy %1 %backupdir%

:: -- Get Name * --
if %1=="" for %%V in (echo goto:End) do %%V Required filename missing.
chdir /d "%sourcesdkmapsdir%"
if exist *. ren *. *.!@#
ren %1 *.
for %%V in (*.) do set {FileName}=%%V
move %{FileName}% %1 > nul
if exist *. ren *. *.vmf
:End

:: -- BSP, VIS, and RAD --
%vbsp% "%{FileName}%.vmf"
%vvis% "%{FileName}%.bsp"
%vrad% "%{FileName}%.bsp"

copy %{FileName}%.bsp %hl2mapsdir%

:: -- Optional pause at end of compile, remove the :: infront of pause to incase you want to review output before window closes --
:: Pause

:: -- Remove the :: infront of the line below if you wish to start the game and load up the map after compile          --
:: -- If you forgot to remove them you have time to close the window if you remove the :: infront of the pause above   --
:: -- Change the %Insert correct game path here% to the proper game path hl2mapsdir/cssmapsdir but DO NOT delete the % --

:: -dev -console +sv_lan 1 +map "%Insert correct game path here%\%{Filename}%.bsp"

:: -- Clear the variables, save some space, no need to touch --

set vbsp=""
set vvis=""
set vrad=""
set sourcesdkmapsdir=""
set hl2mapsdir=""
set cssmapsdir=""
set backupdir=""

For anyone who has not used or seen a batch file before this is how to set it up.
1) Copy the code above (in the code box)
2) Create a new text document
3) Paste code in document
4) Save the document as "batch compile.bat" you can change the "batch compile" part but be sure to have all of that in double qoutation marks if you aren't sure you can rename file extensions. If you can it doesn't matter what extension you have as long as its a plain text file and the ending is .bat
5) To use, just drag and drop the .vmf onto the batch file and if you filled the paths out right start up

*Notes: I have other hints about some things inside the file so read it over before using.

Hope you enjoy it, find it useful, and squeeze that much more out of your pc :thumbs:
 
Back
Top