Exporting Projects Using the Command Line

As an alternative to exporting projects in the Flare user interface, you can use madbuild to export projects from the command line. Using this method, you do not need to have Flare open, and you can schedule exports for specific days and times.

How to Use the Command Line to Export a Project

  1. Add an export project file in the Project Organizer. It will be placed in an Exports folder. See Adding an Export Project File.
  2. Complete the fields in the Export Project File Editor. You need to do this so that Flare knows where to export the project, which parts of it to export, and so on. These fields need to be completed only once. After that, you can export the project anytime you want and these same rules will be used. For more information on each field and option in the Export Project File Editor, see Exporting Projects.
  3. Do one of the following, depending on whether you want to create a batch file for later use or to export immediately using the command line.
    • To Create a Batch File (Recommended) Open Notepad. For example, in Windows 7, you can open it by clicking the Start button and selecting All Programs > Accessories > Notepad.

      OR

    • To Generate Immediately From the Command Line Open your command prompt. For example, in Windows 7, you can open it by clicking the Start button and then selecting All Programs > Accessories > Command Prompt.
  4. Type the path to the Flare.app folder where you installed Flare, and press ENTER.

    Example If you installed Flare at C:\Program Files (this is just an example; your files might be installed in a different folder, such as Program Files x86), you might type the following and press ENTER on your keyboard:

    cd\Program Files\MadCap Software\MadCap Flare 20\Flare.app

    Note Alternatively, you can use cd c:\Program Files\[rest of the path] instead of cd\Program Files\[rest of the path].

  5. Type the following and press ENTER on your keyboard (entering the path to your project, and the export file within it, in place of the section in angle brackets):

    madbuild -export [project path] -settings [export project file name]

    Make sure you add the .flexp file extension at the end of the export project file name.

    Tip If you are using the command prompt (as opposed to a Notepad file) and you have an operating system that supports dragging, you can drag a file from the Windows location to the Command Prompt window. This will add the path of the file within quotation marks for you.

    Note If there are spaces anywhere in your path or project name, you need to use quotation marks around it.

    Example — No Spaces

    You have a Flare project called "FictionSoftPro" that you have stored in a folder of the same name at the root level of the C: drive. Within that project you've created an export file named "MyExportFile." In that case, you can type this:

    madbuild -export c:\FictionSoftPro\FictionSoftPro.flprj -settings MyExportFile.flexp

    Example — Spaces

    You have a project called "FictionSoftPro" that you have stored in a folder named "My Projects" (with a space) at the root level of the C: drive. Within that project you've created an export file named "My Export File" (with spaces). In that case, you can type this:

    madbuild -export "c:\My Projects\FictionSoftPro\FictionSoftPro.flprj" -settings "My Export File.flexp"

    If you are using the command prompt window, the project is exported immediately.

    If you are creating a batch file in Notepad, it might look something like this:

Batch Files and Task Scheduler

If you are creating a batch file, save the Notepad file to any location you like on your computer. When you do this, type .bat as the extension at the end of the file name (e.g., MyBatchFile.bat). At any time you like, you can export the project simply by double-clicking the batch file. You can also use a tool to schedule the batch file to run.

For example, complete the following steps if using the Windows 10 Task Scheduler utility.

  1. In the Windows search field, type Task Scheduler and press ENTER.
  2. Click Action > Create Basic Task.
  3. In the Create Basic Task Wizard, give the task a name and click Next.
  4. Using the next couple of pages of the wizard, choose when you wan the batch to run (e.g., daily, starting at 2 a.m.). Click Next until you get to the Action page.
  5. Click Start a program, and click Next.
  6. Click Browse. Then find and double-click the batch file you created.
  7. Click Next.
  8. Click Finish.

Error Codes

If you export a project using the command line, the following error codes may be seen if problems occur during an export process:

  • 3001 The entered export project file does not exist.
  • 3002 There was an error parsing the entered export project file.
  • 3003 Export failed.
  • 3004 Export destination name not set in the export file
  • 3005 Export destination path not set in the export file
  • 3006 Template name not set in the export file
  • 3007 Template path not set in the export file
  • 3008 Target path not set in export file (when exporting using target)
  • 3009 Target path not found (when exporting using target)
  • 3010 Conditional expression not set (when exporting using conditional expression)
  • 3011 File Tag expression not set (when exporting using file tag expression)
  • 3012 No files selected (when exporting using manual selection)