Can Dopus search in file contents provide a list of contents searched?

I'm looking for an easy way to search the contents of about 450 files for employee names and id numbers. Not sure if this is possible, but it would be great if Dopus could provide a list of line items?

Example: Do a regex search and return the whole line: [^\t\n\r]+\t[0-9]{2}-[0-9]{5}\N+

Which would result in a text file or list of lines like
Mike Jones badge number 55-76762

If it's not possible, that's cool. Just thought I'd ask.


It can tell you which files have contents matching the regex (assuming the files are either plain text or in a format that an IFilter is installed for). But it won't show you a list of the matching lines.

I usually use a text editor for that, as the decent ones have a Find In Files function that'll show all the matching lines as well as open the files for viewing/editing in the same UI.

This script will loop through all selected files and create text files containing regex matching lines next to them. The regex might need some finetuning, but that's the fun part, right?


function OnClick(clickData) {
    var cmd = clickData.func.command;
    var tab = clickData.func.sourcetab;
    var fso = new ActiveXObject('Scripting.FileSystemObject');

    cmd.deselect = false;

    cmd.RunCommand('Set UTILITY=otherlog');
    var regEx = /[^\t\n\r]+\t[0-9]{2}-[0-9]{5}\N+/gi;


    for (var e = new Enumerator(tab.selected_files); !e.atEnd(); e.moveNext()) {
        var item = e.item();
        DOpus.Output('File: ' + item);

        var inFile = fso.OpenTextFile(item, 1);
        var outFile = fso.CreateTextFile(item + '-badges.txt');
        var total = 0;

        while (!inFile.AtEndOfStream) {
            var line = inFile.ReadLine();
            var arrBadges = line.match(regEx) || [];
            var badgeCount = arrBadges.length;
            if (badgeCount == 0) continue;
            total += badgeCount;


        DOpus.Output('  Badges found: ' + total + '\n');
    DOpus.Output('\n... done.');
Button as XML
<?xml version="1.0"?>
<button backcol="none" display="both" label_pos="right" textcol="none">
	<function type="script">
		<instruction>@script JScript</instruction>
		<instruction />
		<instruction>function OnClick(clickData) {</instruction>
		<instruction>    var cmd = clickData.func.command;</instruction>
		<instruction>    var tab = clickData.func.sourcetab;</instruction>
		<instruction>    var fso = new ActiveXObject(&apos;Scripting.FileSystemObject&apos;);</instruction>
		<instruction />
		<instruction>    cmd.deselect = false;</instruction>
		<instruction />
		<instruction>    cmd.RunCommand(&apos;Set UTILITY=otherlog&apos;);</instruction>
		<instruction>    DOpus.ClearOutput();</instruction>
		<instruction>    </instruction>
		<instruction>    var regEx = /[^\t\n\r]+\t[0-9]{2}-[0-9]{5}\N+/gi;</instruction>
		<instruction />
		<instruction>    DOpus.Output(&apos;Enumerating...\n&apos;);</instruction>
		<instruction />
		<instruction>    for (var e = new Enumerator(tab.selected_files); !e.atEnd(); e.moveNext()) {</instruction>
		<instruction>        var item = e.item();</instruction>
		<instruction>        DOpus.Output(&apos;File: &apos; + item);</instruction>
		<instruction />
		<instruction>        var inFile = fso.OpenTextFile(item, 1);</instruction>
		<instruction>        var outFile = fso.CreateTextFile(item + &apos;-badges.txt&apos;);</instruction>
		<instruction>        var total = 0;</instruction>
		<instruction />
		<instruction>        while (!inFile.AtEndOfStream) {</instruction>
		<instruction>            var line = inFile.ReadLine();</instruction>
		<instruction>            var arrBadges = line.match(regEx) || [];</instruction>
		<instruction>            var badgeCount = arrBadges.length;</instruction>
		<instruction>            if (badgeCount == 0) continue;</instruction>
		<instruction>            total += badgeCount;</instruction>
		<instruction>            outFile.WriteLine(line);</instruction>
		<instruction>        }</instruction>
		<instruction />
		<instruction>        inFile.close();</instruction>
		<instruction>        outFile.close();</instruction>
		<instruction />
		<instruction>        DOpus.Output(&apos;  Badges found: &apos; + total + &apos;\n&apos;);</instruction>
		<instruction>    }</instruction>
		<instruction>    DOpus.Output(&apos;\n... done.&apos;);</instruction>

How to use buttons and scripts from this forum

Thanks Leo. I figured it might be beyond the scope of Directory Opus. Currently trialing UltraFinder and it seems to do the job.

DAAAMN!! That's an awesome script! Thank you. I'm going to fiddle around with it and see if I can get all the results to post to a file. But even multi files are VERY helpful. Thanks again!