Welcome to the Mythicsoft Q&A site for:

- Agent Ransack
- FileLocator Lite
- FileLocator Pro

Please feel free to ask any questions on these products or even answer other community member questions.

Useful Links:

- Contact Us
- Help Manuals
- Mythicsoft Home
0 votes

I'm currently using the CSV export from the command line, e.g.

FileLocatorPro.exe -o "C:\output\Found.csv" -oa -ofc -d "C:\Search" -c "Phrase1 OR Phrase2"

but what I would like is for an additional column to show what the specific hit was on each line, e.g.

HIT-TEXT | Path | Name | Size | File Type | Mod date | Hit count | Line # | Text

Where HIT-TEXT would be Phrase1 or Phrase2 (or both) depending on what was found.

by (31.3k points)

1 Answer

0 votes
Best answer

Using a custom XSL Transform format you could achieve what you want.

Save the transform below to a file, e.g. csv_text_with_hits.xsl, then follow the steps in this QA article to export the results using the custom format.

If you want to run it from the command line:

FileLocatorPro.exe -o "C:\output\Found.csv" -oa -d "C:\Search" -c "Phrase1 OR Phrase2" -ofxslt "c:\csv_text_with_hits.xsl"

XSL Transform:

<?xml version="1.0"?>
<!-- CSV Separated export with first column showing hits found on line
    Copyright (C) Mythicsoft Ltd 2015. All rights reserved.

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"

  <xsl:output method="text"/>

  <xsl:param name="quote">"</xsl:param>
  <xsl:param name="single-quote">'</xsl:param>
  <xsl:param name="separator-quote">","</xsl:param>

  <xsl:template match="/">
    <xsl:apply-templates select="//rslt:line"/>
  <xsl:template match="rslt:line">
    <xsl:value-of select="$quote"/>
    <xsl:apply-templates select="rslt:hit"/>
    <xsl:value-of select="$separator-quote"/>
    <xsl:value-of select="../../rslt:path"/>
    <xsl:value-of select="$separator-quote"/>
    <xsl:value-of select="../../rslt:name"/>
    <xsl:value-of select="$separator-quote"/>
    <xsl:value-of select="../../rslt:size"/>
    <xsl:value-of select="$separator-quote"/>
    <xsl:value-of select="../../rslt:type"/>
    <xsl:value-of select="$separator-quote"/>
    <xsl:value-of select="../../rslt:modified"/>
    <xsl:value-of select="$separator-quote"/>
    <xsl:value-of select="@rslt:hitcount"/>
    <xsl:value-of select="$separator-quote"/>
    <xsl:value-of select="@rslt:number"/>
    <xsl:value-of select="$separator-quote"/>
    <xsl:value-of select="translate(rslt:text, $quote, $single-quote)"/>    <!-- double-quotes replaced with single-quotes -->
    <xsl:value-of select="$quote"/>

  <xsl:template match="rslt:hit">
    <xsl:if test="position()>1">
      <xsl:text>, </xsl:text>   <!-- Separate hits with comma -->
    <xsl:value-of select="substring(../rslt:text, @rslt:exprstart + 1, @rslt:exprlength)"/>

by (31.3k points)