!7

p {
  RemoteDB db = new RemoteDB(#1006463, true); // auto start AI Concepts
  L<RC> l = db.xlist("AIConcept");
  print("Found " + n(l, "concepts"));
  for (RC rc : l) {
    S id = rc.getString("globalID");
    S md5 = rc.getString("imageMD5");
    if (empty(md5)) {
      RC pngFile = cast rc.get("pngFile");
      //print("pngFile: " + pngFile);
      if (pngFile != null) {
        S pngPath = pngFile.getString("pngPath");
        print("  PNG path: " + pngPath);
        File png = prepareFile(new File(javaxDataDir(), pngPath));
        pcall {
          BufferedImage img = loadImage2(png);
          if (img != null) {
            md5 = md5OfBufferedImage(img);
            rc.set(imageMD5 := md5);
            print("  Updated MD5 to " + md5);
          }
        }
      }
    }
  }
  db.close();
  print("Done!");
}