#### 2.7.3 Creating a script to run DITA2Go DCL

If you get tired of typing the command-line switches every time you run dcl.exe, you can make yourself a script that calls dcl.exe, using system variable %dcl% (see §2.7.1 Executing the correct version of DCL). You can give the script file any name (except dita2go; that name is reserved), as long as the file has extension .bat.

For example, to create MyD2G.bat:

1. Using a text editor, copy the following line and paste it into a new text file:

       %dcl% -f%1 %2

2. Save the new file in your DITA2Go output directory as "MyD2G.bat", and exit the text editor.

Note: The quote marks are not part of the file name. Their purpose is to prevent the text editor from saving the file as MyD2G.bat.txt, which is what many editors would do otherwise.

Now you can run dcl.exe from the command line as follows:

    MyD2G output_format input_file

For example:

    D:\Tests\HTML> MyD2G html ..\DITATestSuite.ditamap

would produce HTML files in directory HTML, from map file DITATestSuite.ditamap located in directory Tests.

You can customize MyD2G.bat for a particular type of output or for a specific project. For example, to modify MyD2G.bat so it always produces HTML Help:

    %dcl% -f htmlhelp %1

You would run MyD2G.bat as follows:

    MyD2G input_file

For example:

    D:\Tests\MyHHproject> MyD2G ..\DITATestSuite.ditamap

Suppose you always convert a .ditamap; your output directory is always a subdirectory of the directory containing the .ditamap; and you always produce HTML 4.0 output:

    %dcl% -f html ..\%1.ditamap

For a map named ProjectA.ditamap you would run MyD2G.bat as follows:

    MyD2G input_file

For example:

    D:\Maps\ToHTML> MyD2G ProjectA

If the only conversion you are likely to run from your output directory is from ProjectA.ditamap, change the command in MyD2G.bat to:

    %dcl% -f html ..\ProjectA.ditamap

Now you can run MyD2G.bat as follows:

    D:\Maps\ToHTML> MyD2G

See §45. Converting via DCL for additional ways to modify and deploy DCL commands.

Previous Topic: 2.7.2 Understanding how to run DITA2Go DCL

Next Topic: 3. Editing configuration files

Parent Topic: 2.7 Converting documents from the command line

Sibling Topics:

2.7.1 Executing the correct version of DCL

2.7.2 Understanding how to run DITA2Go DCL