4EParser Tutorial 2: Batch Files and Setup Files

From FGWiki

Jump to: navigation, search

Contents

Intro

Setup files and Batch files. Two important shortcuts to help you be über-productive while compiling your modules. Let's get started!

Parser Setup Files

You can save your 4EParser setup (the directories, output info, etc.) to be loaded for a later session. It seems to refer to them as both Setup and Definiton files; we'll just call them setup files for simplicity.

They're very useful since you will be switching back and forth among various modules, all with their own directories/files. Plus it's not the most stable of programs, tending to crash now and then. Save yourself some headaches and save your setups!

Once you have 4EParser setup the way you like it, simply go to its File menu and click "Save". You can name it whatever you like. Don't forget to re-save your setup if you make any changes to it. Sounds obvious, but I've made this mistake more than once.

It would be a good idea to save a separate Setup for each module you are creating. I recommend keeping these in the root directory of your working folder for that particular module. An example of what one of my working directories looks like is shown at the end of this tutorial.

Batch Files

4EParser supports batch files. A batch file is a text file containing a series of commands intended to be executed by the command interpreter. When a batch file is run, the shell program (usually cmd.exe) reads the file and executes its commands.

Their primary use in 4EParser is to zip up modules of your output data and place them in FGII's module folder and overwriting/removing the old ones, if they exist.

If you intend to be using the 4EParser for any length of time, this is a process you would ordinary need to do by hand many, many times, especially while troubleshooting typos and other errors in your input data. Basically, they makes users of the 4E Parser's lives much, much easier!

Take note of your directories

  • WinRAR executable location. Usually C:\Program Files\WinRAR\WinRAR.exe. You can use 7-zip or something else, provided it can be used via command line and you know the commands and switches it recognizes. Your archiver's help file is your friend. So is Google.
  • Fantasy Grounds II module folder.
    • default on Vista is: C:\Users\username\AppData\Roaming\Fantasy Grounds II\modules\
    • default on Win XP is: C:\Documents and Settings\username\Application Data\Fantasy Grounds II\modules\
  • The 4EParser output path for the module this batch file is intended for.

It is good practice to use a separate output path (where the parser outputs the .xml files) than where you keep your input data (the "Data Files" like MMdata.txt and MMfluf.txt).

I use a separate folder for each book/adventure/module, and a sub-folder inside it for the output data. So for example:

  • C:\4EParser\MonsterManual\ might be where you save all your data files.
  • C:\4EParser\MonsterManual\MonsterManual\ might be the directory you have all the output sent to.

This works nicely since everything pertaining to that particular module is with one folder.

Command line switches for your file archiver

WinRAR accepts commands via the command line like so:

WinRAR.exe <command> -<switch1> -<switchN> <archive> <files...>

We will really only be needing one command for this tutorial: A, which is add to archive. We will use these switches:

  • -afzip : tells WinRAR to make the archive in .zip format. It probably does by default, but we need to make sure it doesn't use .rar!
  • -r : recursive directories. this makes sure it adds any sub directories. This will be important if you use tokens, which are always in the "tokens" sub-directory of your output folder. Tokens will be covered in a later tutorial.
  • -ep1 : exclude base folder from filenames.

A simple batch file example

Create an empty ASCII text file. Enter the following:

del "C:\Users\username\AppData\Roaming\Fantasy Grounds II\modules\4eMonsterManualI.mod"
"C:\Program Files\WinRAR\WinRAR.exe" a -afzip -r -ep1 "C:\Users\username\AppData\Roaming\Fantasy Grounds II\modules\4eMonsterManualI.mod" "C:\Parser\4eMonsterManualI\4eMonsterManualI\*.*"

Note my directories are for a Vista system, on XP they will be slightly different. This batch file does the following, in order:

  • deletes the old module, if it exists in that directory
  • evokes WinRAR and creates a zip file named 4eMonsterManualI.mod (note the extension. no renaming the .zip to .mod is required if you do it this way!) which includes the contents of the folder you specify, and all of its subfolders.
  • places it in your FGII modules folder

Just replace the paths with whatever corresponds to your system, and use whatever filename you prefer for the .mod file. Pretty simple!

Save this with the .bat extension. I would recommend keeping this in your working folder for that specific module, along with your 4EParser Setup file.

Every time the parser has completed a parse, it will run the batch file, assuming you told the parser one exists. You will see the blue Batch File link at the top of 4EParser, under 'Output' settings. Remember: re-save your Setup file.

Other batch file examples

Feel free to edit this article and add your own batch file examples (particularly for archivers other than WinRAR).

Productivity ftw!

Just to show you an example of how this all works together, here's what my Monster Manual I directory looks like: Image:4eparser working directory.jpg

  • parser output folder
  • notes, where I keep a list of to-dos for this module, or bugs/workarounds I had to deal with
  • notepad++ saved session
  • 4EParser Setup file
  • batch file
  • other input data and reference material

Happy parsing!

Personal tools