public BatchSessionSearcher search() {

    final long tstart = System.currentTimeMillis();
    this.openOutputFile();
    final String dir = this.globalConf.getFileCopyLocalTargetDir();
    final String searchTerm = this.globalConf.getUserSearchTerm();
    if (searchTerm == null || searchTerm.length() == 0) {
      LOGGER.info("Invalid search term");
      return this;
    }
    LOGGER.info("Searching directory : " + dir);
    LOGGER.info(">> Searching for term '" + searchTerm + "'");
    final File fd = new File(dir);
    if (!fd.isDirectory()) {
      LOGGER.info("Target path is not a directory, exiting");
      return this;
    }
    int totalAllFiles = 0;
    int lastIdValue = 0;

    if (globalConf.isUseXMLPropertyFormat()) {
      this.printWriter.println("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>");
      this.printWriter.println("<!DOCTYPE properties SYSTEM \"http://java.sun.com/dtd/properties.dtd\">");
      this.printWriter.println("<properties>");
    }
    for (final File f : fd.listFiles()) {
      if (f.isDirectory()) {
        continue;
      }
      final BasicSesssionCollector s = new BasicSesssionCollector(globalConf, sessionDatabase);
      s.writeOutputFile = this.writeOutputFile;
      s.outputFilename = this.outputFilename;
      s.setPrintWriter(printWriter);
      s.lastIdValue = lastIdValue;
      s.search(regexSessionPattern, f);
      lastIdValue = s.id;
      totalAllFiles += s.getTermFoundTotal();
    } // End of the For //
    // Write the full session database to file //
    final BasicSesssionCollector s = new BasicSesssionCollector(globalConf, sessionDatabase);
    s.writeOutputFile = this.writeOutputFile;
    s.outputFilename = this.outputFilename;
    s.setPrintWriter(printWriter);
    s.writeSessionDatabase();
    if (globalConf.isUseXMLPropertyFormat()) {
      this.printWriter.println("</properties>");
    }
    this.statsTotalSearchFound = totalAllFiles;
    this.close();
    final long tdiff = System.currentTimeMillis() - tstart;
    LOGGER.info(">> Found term '" + searchTerm + "' total of = " + this.statsTotalSearchFound + " times in files");
    LOGGER.info(">> Found term in " + tdiff + " ms , " + (tdiff / 1000.0) + " seconds");

    final double mb = 1024.0 * 1024;
    final double free = Runtime.getRuntime().freeMemory() / mb;
    final double total = Runtime.getRuntime().totalMemory() / mb;
    final double max = Runtime.getRuntime().maxMemory() / mb;
    final String fmt = String.format("Memory after operation [ freeMemory=%.2fM total=%.2fM maxMemory=%.2fM ]", free, total, max);
    LOGGER.info(fmt);
    return this;
  }