Welcome to the IDM Forum. This forum is meant as a user-to-user support mechanism where users can share knowledge and tips for all IDM software.
Since these forums are user-to-user based, IDM does not regularly read or reply to the posts in this forum. For problem reports, suggestions, or feature requests, you must email us directly. Our trained technical support staff answers most inquiries within 30 minutes.
if (UltraEdit.document.length > 0)
{
// Define the environment for the script.
UltraEdit.insertMode();
UltraEdit.columnModeOff();
UltraEdit.activeDocument.hexOff();
// Select all and load the file contents into an array of lines.
UltraEdit.activeDocument.selectAll();
if (UltraEdit.activeDocument.isSel())
{
// The following command works only for files with DOS line terminators!
var asLines = UltraEdit.activeDocument.selection.split("\r\n");
UltraEdit.activeDocument.top();
// Define parameters for the Find in Files executed below in a loop for every line.
UltraEdit.frInFiles.filesToSearch=0; // Search in a directory.
UltraEdit.frInFiles.directoryStart="C:\\Temp\\"; // This is the directory.
UltraEdit.frInFiles.searchInFilesTypes="*.*"; // Search in these files.
UltraEdit.frInFiles.useEncoding=false; // Run an ANSI search.
UltraEdit.frInFiles.ignoreHiddenSubs=true; // Ignore hidden subdirectories.
UltraEdit.frInFiles.matchCase=true; // Run a case sensitive search.
UltraEdit.frInFiles.reverseSearch=false; // Do not find files not containing searched string.
UltraEdit.frInFiles.matchWord=false; // Search for strings and not entire words.
UltraEdit.frInFiles.openMatchingFiles=false; // Do not open files with string found.
UltraEdit.frInFiles.displayLinesDoNotMatch=false; // Do not find lines not containing search string.
UltraEdit.frInFiles.useOutputWindow=false; // Output find result to edit window.
UltraEdit.frInFiles.searchSubs=false; // Do not search in subdirectories.
UltraEdit.frInFiles.regExp=false; // Run a non regular expression search.
// Run a Find in Files for all lines in active document. This find does
// not make sure that the found string is really an entire line in the
// search files. So it can be that also lines are found which contains
// the searched string, but also additional characters left and/or right.
for (var nLineNum = 0; nLineNum < asLines.length; nLineNum++)
{
if (!asLines[nLineNum].length) continue; // Ignore empty lines.
UltraEdit.frInFiles.find(asLines[nLineNum]);
}
// The results file is the active file now. Move caret to top
// of this file and convert the file from Unicode to ASCII/ANSI.
UltraEdit.activeDocument.top();
UltraEdit.activeDocument.unicodeToASCII();
}
}
UltraEdit.frInFiles.directoryStart="C:\\Temp\\"; // This is the directory.
UltraEdit.frInFiles.searchInFilesTypes=".txt"; // Search in these files.



11111-22222-33333-44444-55555
aaaaa-bbbbb-ccccc-ddddd-eeeee
11111-22222-33333-44444-555551111122222333334444455555
aaaaabbbbbcccccdddddeeeee
111112222233333444445555511112222333344445555
aaaabbbbccccddddeeee
1111222233334444555511111-22222-33333-44444-55555
11112222333344445555
aaaaa-bbbbb-ccccc-ddddd-eeeee
11111-22222-33333-44444-55555
1111122222333334444455555
11112222333344445555
11111-22222-33333-44444-555551111122222333334444455555
aaaaabbbbbcccccdddddeeeee
111112222233333444445555511111-22222-33333-44444-55555
aaaaa-bbbbb-ccccc-ddddd-eeeee
111112222233333444445555588811-22222-33333-44444-55555----------------------------------------
Find '11111-22222-33333-44444-55555' in 'C:\Temp\Test2.txt':
C:\Temp\Test2.txt(1): 11111-22222-33333-44444-55555
Found '11111-22222-33333-44444-55555' 1 time(s).
Search complete, found '11111-22222-33333-44444-55555' 1 time(s). (1 file(s)).
Search complete, found '11112222333344445555' 0 time(s). (0 file(s)).
----------------------------------------
Find 'aaaaa-bbbbb-ccccc-ddddd-eeeee' in 'C:\Temp\Test2.txt':
C:\Temp\Test2.txt(2): aaaaa-bbbbb-ccccc-ddddd-eeeee
Found 'aaaaa-bbbbb-ccccc-ddddd-eeeee' 1 time(s).
Search complete, found 'aaaaa-bbbbb-ccccc-ddddd-eeeee' 1 time(s). (1 file(s)).
----------------------------------------
Find '11111-22222-33333-44444-55555' in 'C:\Temp\Test2.txt':
C:\Temp\Test2.txt(1): 11111-22222-33333-44444-55555
Found '11111-22222-33333-44444-55555' 1 time(s).
Search complete, found '11111-22222-33333-44444-55555' 1 time(s). (1 file(s)).
----------------------------------------
Find '1111122222333334444455555' in 'C:\Temp\Test1.txt':
C:\Temp\Test1.txt(1): 1111122222333334444455555
C:\Temp\Test1.txt(3): 1111122222333334444455555
Found '1111122222333334444455555' 2 time(s).
----------------------------------------
Find '1111122222333334444455555' in 'C:\Temp\Test2.txt':
C:\Temp\Test2.txt(3): 1111122222333334444455555
Found '1111122222333334444455555' 1 time(s).
Search complete, found '1111122222333334444455555' 3 time(s). (2 file(s)).
Search complete, found '11112222333344445555' 0 time(s). (0 file(s)).
----------------------------------------
Find '11111-22222-33333-44444-55555' in 'C:\Temp\Test2.txt':
C:\Temp\Test2.txt(1): 11111-22222-33333-44444-55555
Found '11111-22222-33333-44444-55555' 1 time(s).
Search complete, found '11111-22222-33333-44444-55555' 1 time(s). (1 file(s)).Running script: C:\Program Files\IDM Computer Solutions\UltraEdit\scripts\FindLinesInTextFiles.js
========================================================================================================
Script succeeded.----------------------------------------
C:\Temp\Test2.txt(1): 11111-22222-33333-44444-55555
Found '11111-22222-33333-44444-55555' 1 time(s) in 1 file(s).
----------------------------------------
Found '11112222333344445555' 0 time(s) in (0 file(s).
----------------------------------------
C:\Temp\Test2.txt(2): aaaaa-bbbbb-ccccc-ddddd-eeeee
Found 'aaaaa-bbbbb-ccccc-ddddd-eeeee' 1 time(s) in 1 file(s).
----------------------------------------
C:\Temp\Test1.txt(1): 1111122222333334444455555
C:\Temp\Test1.txt(3): 1111122222333334444455555
C:\Temp\Test2.txt(3): 1111122222333334444455555
Found '1111122222333334444455555' 3 time(s) in 2 file(s).