code: def batchseeds(args):
      
      from jcvi.formats.pdf import cat
  
      xargs = args[1:]
      p = OptionParser(batchseeds.__doc__)
      opts, args, iopts = add_seeds_options(p, args)
  
      if len(args) != 1:
          sys.exit(not p.print_help())
  
      folder, = args
      folder = folder.rstrip('/')
      outdir = folder + "-debug"
      outfile = folder + "-output.tsv"
      assert op.isdir(folder)
      images = []
      jsonfile = opts.calibrate or op.join(folder, "calibrate.json")
      if not op.exists(jsonfile):
          jsonfile = None
      for im in iglob(folder, "*.jpg,*.JPG,*.png"):
          if im.endswith((".resize.jpg", ".main.jpg", ".label.jpg")):
              continue
          if op.basename(im).startswith("calibrate"):
              continue
          images.append(im)
  
      fw = must_open(outfile, 'w')
      print(Seed.header(calibrate=jsonfile), file=fw)
      nseeds = 0
      for im in images:
          imargs = [im, "--noheader", "--outdir={0}".format(outdir)] + xargs
          if jsonfile:
              imargs += ["--calibrate={0}".format(jsonfile)]
          objects = seeds(imargs)
          for o in objects:
              print(o, file=fw)
          nseeds += len(objects)
      fw.close()
      logging.debug("Processed {0} images.".format(len(images)))
      logging.debug("A total of {0} objects written to `{1}`.".\
                      format(nseeds, outfile))
  
      pdfs = iglob(outdir, "*.pdf")
      outpdf = folder + "-output.pdf"
      cat(pdfs + ["--outfile={0}".format(outpdf)])
  
      logging.debug("Debugging information written to `{0}`.".format(outpdf))
      return outfile
docs: %prog batchseeds folder
  
      Extract seed metrics for each image in a directory.