Export the matched string 'Find in text'

English support forum

Moderators: Hacker, petermad, Stefan2, white

Oesie
Junior Member
Junior Member
Posts: 18
Joined: 2012-04-21, 07:58 UTC

Export the matched string 'Find in text'

Post by *Oesie »

When using the 'Search' (Alt + F7) option with the 'Find text' checkbox enabled you can search 'inside' a file. Is there a way to export the matched strings to a file (so not the filename itself where the match is found)?

Update 27 feb: Updated the example to not only refer a txt file but also pdf and other formats.

Example files test.pdf, test.docx or test.txt containing:

Code: Select all

Some text on rule 1.
Some text on rule 2 with more data and numbers.
Example search (find a string that contains the word 'text' and 'data'):
rule.*data.*

When running the search the string 'Some text on rule 2 with more data and numbers.' is matched from all the files. Is there a way to export the matched string results?

Update 27 feb: For plain text files the FINDSTR command is given. Is there tooling for the other formats (i.e. docx, xlsx, pdf, pptx)?
Last edited by Oesie on 2025-02-27, 10:39 UTC, edited 2 times in total.
User avatar
white
Power Member
Power Member
Posts: 5744
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Re: Export the matched string 'Find in text'

Post by *white »

No, you will have to use other tools for that. For example:

Code: Select all

FINDSTR /i /r /c:"rule.*data" *.* > "results.txt"
User avatar
Dalai
Power Member
Power Member
Posts: 9943
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Re: Export the matched string 'Find in text'

Post by *Dalai »

Be aware that putting placeholders in the "Find text" field like .* will only work when RegEx are enabled. Otherwise they're search for literally.
#101164 Personal licence
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64

Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
Oesie
Junior Member
Junior Member
Posts: 18
Joined: 2012-04-21, 07:58 UTC

Re: Export the matched string 'Find in text'

Post by *Oesie »

white wrote: 2025-02-26, 10:43 UTC No, you will have to use other tools for that. For example:

Code: Select all

FINDSTR /i /r /c:"rule.*data" *.* > "results.txt"
This works great for plain text files, thanks!
Do you know or recommend tooling that can do the same for pdf, docx, xlsx, pptx files?

I will update the first post.
User avatar
white
Power Member
Power Member
Posts: 5744
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Re: Export the matched string 'Find in text'

Post by *white »

Oesie wrote: 2025-02-27, 09:57 UTC Do you know or recommend tooling that can do the same for pdf, docx, xlsx, pptx files?
Sadly, no.
Oesie
Junior Member
Junior Member
Posts: 18
Joined: 2012-04-21, 07:58 UTC

Re: Export the matched string 'Find in text'

Post by *Oesie »

That's a pity.

@white, do you know as moderator, if a feature request for this have any chance to get implemented if submitted?
User avatar
Dalai
Power Member
Power Member
Posts: 9943
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Re: Export the matched string 'Find in text'

Post by *Dalai »

Oesie wrote: 2025-02-27, 09:57 UTCDo you know or recommend tooling that can do the same for pdf, docx, xlsx, pptx files?
I can't remember to have come across such a request. IMO the only thing you can do is look around the web to find a tool which is able to do this. Command line tools are the most likely group to have something like this, but GUI tools could also have such a feature.

Now that I come to think of it: LibreOffice has a feature "Search all" (or "Find all", not sure what the English term is) which is able to show all hits in a neat little table. Doesn't look like this table can be copied to clipboard, though.
#101164 Personal licence
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64

Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
Oesie
Junior Member
Junior Member
Posts: 18
Joined: 2012-04-21, 07:58 UTC

Re: Export the matched string 'Find in text'

Post by *Oesie »

Dalai wrote: 2025-02-27, 12:05 UTC
Oesie wrote: 2025-02-27, 09:57 UTCDo you know or recommend tooling that can do the same for pdf, docx, xlsx, pptx files?
I can't remember to have come across such a request. IMO the only thing you can do is look around the web to find a tool which is able to do this. Command line tools are the most likely group to have something like this, but GUI tools could also have such a feature.

Now that I come to think of it: LibreOffice has a feature "Search all" (or "Find all", not sure what the English term is) which is able to show all hits in a neat little table. Doesn't look like this table can be copied to clipboard, though.
Yeah I'm currently searching for the CLI tools that can do this.
Another option is to convert PDF to plain text files and perform the FINDSTR command above on those files.

However, since Total Commander (and its content plugins) have all the information at hand an output of that information might be easy?
User avatar
white
Power Member
Power Member
Posts: 5744
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Re: Export the matched string 'Find in text'

Post by *white »

Oesie wrote: 2025-02-27, 11:27 UTC @white, do you know as moderator, if a feature request for this have any chance to get implemented if submitted?
My role as a moderator doesn’t give me special insight into what gets implemented. I suspect it has little chance since the functionality is easy to suggest but tough to build. Still, if nobody requests it, it will almost certainly not happen. And even if it doesn’t get implemented, the discussion will likely be interesting and useful.
User avatar
white
Power Member
Power Member
Posts: 5744
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Re: Export the matched string 'Find in text'

Post by *white »

Oesie wrote: 2025-02-27, 12:18 UTC However, since Total Commander (and its content plugins) have all the information at hand an output of that information might be easy?
I don't think so. The lines that contain the search string are not at hand.

And what should be displayed when searching .exe files?
And how should the results be displayed?
And should it be integrated with the current search function or implemented as separate function? And how exactly?

As said, easier said than done.
User avatar
AntonyD
Power Member
Power Member
Posts: 1554
Joined: 2006-11-04, 15:30 UTC
Location: Russian Federation

Re: Export the matched string 'Find in text'

Post by *AntonyD »

Yeah I'm currently searching for the CLI tools that can do this.
https://pdfgrep.org/
https://github.com/phiresky/ripgrep-all

Or simply to create a proper Python code for searching among mentioned types of files:

Just initiate the proper modules:
import fitz # PyMuPDF (PDF)
import docx # python-docx (DOCX)
import openpyxl # (XLSX)
import pptx # (PPTX)

and go on))))))
#146217 personal license
Oesie
Junior Member
Junior Member
Posts: 18
Joined: 2012-04-21, 07:58 UTC

Re: Export the matched string 'Find in text'

Post by *Oesie »

white wrote: 2025-02-27, 12:31 UTC
Oesie wrote: 2025-02-27, 11:27 UTC @white, do you know as moderator, if a feature request for this have any chance to get implemented if submitted?
My role as a moderator doesn’t give me special insight into what gets implemented. I suspect it has little chance since the functionality is easy to suggest but tough to build. Still, if nobody requests it, it will almost certainly not happen. And even if it doesn’t get implemented, the discussion will likely be interesting and useful.
Ok. Is there any preference in making a suggestion? Or can this topic be moved to the 'TC Suggestions'? If needed the first post can be updated.
white wrote: 2025-02-27, 12:40 UTC
Oesie wrote: 2025-02-27, 12:18 UTC However, since Total Commander (and its content plugins) have all the information at hand an output of that information might be easy?
I don't think so. The lines that contain the search string are not at hand.

And what should be displayed when searching .exe files?
And how should the results be displayed?
And should it be integrated with the current search function or implemented as separate function? And how exactly?

As said, easier said than done.
You're right, easier said than done.

Use case: Parsing the found strings, together with the path/filename, with the 'Search' (Alt + F7) to a a text file (for further processing/analysis). Resulting in something like this (when doing a regex search for a line containing FOUND using plugins):

Code: Select all

D:\Textdocument.txt   "this is FOUND text on a rule"
D:\Temp\PortableDocumenFormat.pdf   "FOUND in a pdf doc"
D:\Search_in_Word.docx   "another line with FOUND"
Maybe a better example is a file with a fixed format but with a variable that is changing, in example an invoice in PDF format.
  • Let's say I want to extract all strings that starts with USD and ends with - so I know what amounts are being invoiced.
  • Process a search within Total Commander for all PDF files using a content plugin (i.e. xPDFsearch) and set a regex search for USD.*-$.
  • All files are being shown where a match is found (i.e. invoice1.pdf, invoice2.pdf, invoice3.pdf
  • (new button) - Export search result (filename + found string)
Resulting in:

Code: Select all

Invoice1.pdf USD 20-
Invoice2.pdf USD 12-
Invoice3.pdf USD 100-
Invoice4.pdf USD 73-
User avatar
white
Power Member
Power Member
Posts: 5744
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Re: Export the matched string 'Find in text'

Post by *white »

Oesie wrote: 2025-02-27, 13:23 UTC Ok. Is there any preference in making a suggestion? Or can this topic be moved to the 'TC Suggestions'? If needed the first post can be updated.
Whatever you like. There is no preference.
User avatar
Dalai
Power Member
Power Member
Posts: 9943
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Re: Export the matched string 'Find in text'

Post by *Dalai »

2Oesie
Well, what about multiple matches? Currently TC searches until the first match. But I can imagine that it's possible to implement something like this with a content plugin, but it only makes sense in conjunction with a custom columns view (not TC's search).
#101164 Personal licence
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64

Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
Oesie
Junior Member
Junior Member
Posts: 18
Joined: 2012-04-21, 07:58 UTC

Re: Export the matched string 'Find in text'

Post by *Oesie »

AntonyD wrote: 2025-02-27, 13:07 UTC
Yeah I'm currently searching for the CLI tools that can do this.
https://pdfgrep.org/
https://github.com/phiresky/ripgrep-all

Or simply to create a proper Python code for searching among mentioned types of files:

Just initiate the proper modules:
import fitz # PyMuPDF (PDF)
import docx # python-docx (DOCX)
import openpyxl # (XLSX)
import pptx # (PPTX)

and go on))))))
Thanks, will look into those.
white wrote: 2025-02-27, 13:39 UTC
Oesie wrote: 2025-02-27, 13:23 UTC Ok. Is there any preference in making a suggestion? Or can this topic be moved to the 'TC Suggestions'? If needed the first post can be updated.
Whatever you like. There is no preference.
Let's see if this topic evolves a bit more.
Dalai wrote: 2025-02-27, 13:41 UTC 2Oesie
Well, what about multiple matches? Currently TC searches until the first match. But I can imagine that it's possible to implement something like this with a content plugin, but it only makes sense in conjunction with a custom columns view (not TC's search).
Didn't know that only the first match is done. Within the example about invoices it don't matter since the format is the same and only one result is possible. But this search is done with a content plugin.

In what way are you thinking about custom columns for this search?
Post Reply