# 1st grade programming help



## hat (Nov 20, 2009)

I have some 430 quake maps I want to vispatch. The process goes like this... normally. There are 2 .exes you need to use that do nothing on thier own. First, you must get the .prt information for the map before you can actually vispatch the map, so you click and drag whatever map you're going to vispatch over bsp2prt.exe. It creates a .prt file with the name of that map (for example, if I want to vispatch 9terrors.bsp, when I click-and-drag it over bsp2prt.exe 9terrors.prt is created).

I've been able to make it work in a batch file for one map at a time like this:
bsp2prt.exe 9terrors

it would make the .prt file for 9terrors.

Then I tried doing two at once...

bsp2prt.exe a2
bsp2prt.exe a3
and it would make a2.prt and a3.prt

I want to make it run through all 430 of my maps so that I don't have to type bsp2prt.exe 430 times and then type 430 map names. Not only is this a long, greuling process, but it leaves a lot of room for errors, and I would have to do it *again* for the actual vispatch process.

Is there any way I can program the batch file to run through all the maps so that I don't have to click and drag almost 900 times (or write 900 lines of code) and gain a huge case of carpal tunnel? It would also greatly speed things up as well. The vispatch process is very slow but the process where it makes the .prt files is pretty much lightning fast, so fast that by the time I click and drag the next map over it's already done with the first map. This would make things much easier on me and speed things up as well.


----------



## Disparia (Nov 20, 2009)

Perhaps...


```
forfiles /M *.bsp /C "bsp2prt.exe @FILE"
```


----------



## hat (Nov 20, 2009)

sorry, I'm a complete newb at this. What does that mean?


----------



## imperialreign (Nov 20, 2009)

hat said:


> sorry, I'm a complete newb at this. What does that mean?



It's been a long while since I've done any work with .bat files, but unless I'm mistaken:


*forfiles * - functions as a loop - for all files with .bsp extension do

*"bsp2prt.exe @FILE"*


not sure on the flags, though - can't remember ATM.


----------



## hat (Nov 20, 2009)

Using Jizzler's line there, I get a bunch of errors. Apparantly it just opened bsp2prt a bunch of times and didn't actaully run it in conjuction with the map. So I tried this:
forfiles /m "bsp2prt.exe" /c "*.bsp @FILE" it said the system could not find the file specified.

apparantly bsp2prt.exe isn't considered to be a file.


----------



## NastyHabits (Nov 20, 2009)

You could try a standard for-loop where one of the arguments is a list of the files.  
you could make a list of the files just by doing *dir *.* > files.txt* at the command prompt in the directory were all your files are, then edit out everything but the file names.  For the exact for-loop syntax see: for-loop  Example 4 is what you want.


----------



## hat (Nov 20, 2009)

I got a bunch of crap along with the filenames. It's a lot of deleting but it helps.

nevermind, I used the /b switch

thanks so far! I'll see what I can do with this


----------



## hat (Nov 20, 2009)

okay, now that I have a list of filenames, is there any way I could make bsp2prt open all my maps at once?


----------



## FordGT90Concept (Nov 20, 2009)

How much time does it take to do just one map assuming it were handled instanteously (no user involvement)?

bsp2prt.exe is a console app, no?


You could try this:

```
FOR /F %%a IN (files.txt) DO bsp2prt.exe "%%a"
```
files.txt is a text file which contains every file to process, one per line (dir *.* > files.txt would have created it).


----------



## Kreij (Nov 20, 2009)

I think he wants to do ...  dir *.bsp > bspfiles.txt, so he only gets the ones he needs for maps.
Otherwise, Ford's code should work fine.


----------



## hat (Nov 23, 2009)

FordGT90Concept said:


> How much time does it take to do just one map assuming it were handled instanteously (no user involvement)?
> 
> bsp2prt.exe is a console app, no?
> 
> ...



This worked. I have all the .prt files now (well, 388 out of 394, the bsp2prt program isn't perfect and some maps just won't produce fruit for some reason).

Now... would you mind explaining to me what that code means, or pointing me to a guide of some sort that can tell me?

Now all I have to do is the vispatch process, which will take... forever. Vispatching is very slow.


----------



## FordGT90Concept (Nov 23, 2009)

for is the executable (actual name is forfiles.exe, for is an alias)
/F is a flag that tells the for command to work with a file set
%a defines a variable named %a which will contain the data read from files.txt (the extra percent sign is required to escape the real percent sign)
IN is a command followed by a source to get the files from
files.txt is where the list of files resides
DO is a command followed by an acction to perform on each object found
bsp2prt.exe "%a" runs bsp2prt with the file name replacing %a


Read like text:

for each file as variable %a in files.txt, do "bsp2prt.exe %a"


This site has info for the FOR command: http://www.computerhope.com/forhlp.htm


The only way to speed up the compiling process without sacrificing quality is to multithread it.  You'll have to look up the compiler help for how to force it to multithread.  If it is the zoner compiler, you use the -threads parameter.


----------



## hat (Nov 25, 2009)

So % defines a variable and the "a" doesn't really carry any significant meaning? I could have had %%q if I wanted to?


----------



## NastyHabits (Nov 26, 2009)

hat said:


> So % defines a variable and the "a" doesn't really carry any significant meaning? I could have had %%q if I wanted to?



No.  %% has a different meaning than %a or %z or what have you.


----------



## FordGT90Concept (Nov 26, 2009)

%a means a variable in commandline but this is not a commandline, it is a batch where % is an escape character.  When it is parsed, the first percent, therefore, goes away leaving %a which the batch sends to the commandline.  %%q would have worked just as well as %%a so long as they all match.  %%file would probably be the most appropriate.


----------



## hat (Nov 26, 2009)

FordGT90Concept said:


> %a means a variable in commandline but this is not a commandline, it is a batch where % is an escape character.  When it is prased, the first percent, therefore, goes away leaving %a which the batch sends to the commandline.  %%q would have worked just as well as %%a so long as they all match.  %%file would probably be the most appropriate.



yeah, that's what I meant.


----------

