code: function exportDiagramBulk(diagrams, filename, format, options, fn) {
      diagrams = diagrams || [];
      filename = filename || "<%=diagram.name%>.png";
      format   = format   || "png";
      options  = options  || {};
  
      // if elements parameter is selector expression, retrieve them from Repository.
      if (_.isString(diagrams)) {
          diagrams = mdjson.Repository.select(diagrams) || [];
      }
  
      _.extend(options, {
          mdjson   : mdjson,
          root     : mdjson.getRoot()
      });
  
      // Append predefined filters
      if (!options.filters) {
          options.filters = {};
      }
      _.extend(options.filters, filters);
  
      var renderedFilename = "";
      for (var i = 0, len = diagrams.length; i < len; i++) {
          try {
              options.diagram = diagrams[i];
              renderedFilename = ejs.render(filename, options);
              fs.ensureFileSync(renderedFilename);
              if (format === "png") {
                  exportDiagramAsPNG(options.diagram, renderedFilename);
              } else if (format === "svg") {
                  exportDiagramAsSVG(options.diagram, renderedFilename);
              }
              if (_.isFunction(fn)) {
                  fn(null, renderedFilename, options.diagram);
              }
          } catch (err) {
              if (_.isFunction(fn)) {
                  fn(err);
              }
          }
      }
  }
docs: Export a set of diagrams at once
  
  @param{Array.<Diagram> | string} diagrams Array of diagrams or selector expression to be exported
  @param{string} filename File name for output image file(s). You can use ejs expression (Default: `<%=diagram.name%>.png`)
  @param{string} format Image format ("png" or "svg").
  @param{Object} options Options used for ejs rendering
  @param{function(err, file, elem)} fn Function to be called for each diagram is exported