For just two keywords and on small files with less than 100 KiB it would be the fastest to use the Perl regular expression search string (?s)\bcat\b.+\bdog\b|\bdog\b.+\bcat\b
to find files containing cat and dog or dog and cat
But this approach is not useful to find files which must contain multiple words. For such cases an UltraEdit script is required. I can imagine two different approaches:
- The script uses Find in Files to search all files for first word with output written to output window. The script takes the file names from output window containing the first word and store them in a string array (first file names list). Then the script uses Find in Files again with second word and again takes the file names containing this second word and store them in an additional string array (second file names list). This procedure is done for each keyword. Finally the script takes one file name after the other from first first file names list and searches for this file name in all other file names list. Each file name from first file names list found in all other file names list is output into the output window to get finally the list of file names containing all words.
- The script uses Find in Files to search all files for first word with output written to output window. The script takes the file names from output window containing the first searched word and store them in a file names list. Next the script searches just in each file in the file names list for second keyword and remove a file name from the list if the file does not contain second keyword. This Find in Files on each file in file names list is done for each keyword until the file names list becomes empty (no file contains all keywords) or all keywords have been searched and the final file names list contains only the names of the files containing all keywords which is written to output window.
The second approach is most likely faster, especially if the thousands of files to search for is reduced already after first search to just a few files.
But UltraEdit's Find in Files
is not really designed for that task. It would be best for this task if searching for a keyword in a file is immediately stopped on having found first occurrence of the keyword in the file, then reset position in file to beginning and search for next word and if this word is also found somewhere in file, reset position in file again to beginning and search for third word and so on until either all words were found in file or one word is not found. Then this loop is applied on next file. That would be much more efficient, but is not possible with Find in Files
. This approach could be used only on opening each file and using regular Find
function for each word in file content (display updates reduced to minimum resulting in faster finishing). But opening each file in UltraEdit on thousands of files to use this method can be slower than using the second Find in Files
when the number of files containing first searched word is low.
The time required to finish this special search task depends extremely on the number of window updates which takes much more time than searching for a word in a small file. UltraEdit as text editor is not designed for doing something completely in background with no visual indication for the user. So my last advice is writing for this task a PowerShell script and call this PowerShell script via a user tool with the parent directory for the search as first parameter and the words every file must contain as further arguments. This would be definitely the fastest method for this special search task.