Hi,
I think I have a simple script request but can't find an answer to it anywhere. Is it even possible?
I simply want to copy all lines that contain a certain text and paste them into a new document.
Yes, I know about the script example given that will iterate through each find, copy a line and continue. This works.. but it's soo slow that it's faster for me to do the operation manually, using the "List lines containing string" option.
Basically, the action I really want to do is this:
- open find dialog with "List lines containing string" option checked
- select "Clipboard" button in the dialog that appears listing all lines containing this string
- paste clipboard text into new document
Can someone help me with this?? I'd really appreciate it!
ps: the code I have today is below.. it's just too darn slow on large log files that it's not worth using.
I think I have a simple script request but can't find an answer to it anywhere. Is it even possible?
I simply want to copy all lines that contain a certain text and paste them into a new document.
Yes, I know about the script example given that will iterate through each find, copy a line and continue. This works.. but it's soo slow that it's faster for me to do the operation manually, using the "List lines containing string" option.
Basically, the action I really want to do is this:
- open find dialog with "List lines containing string" option checked
- select "Clipboard" button in the dialog that appears listing all lines containing this string
- paste clipboard text into new document
Can someone help me with this?? I'd really appreciate it!
ps: the code I have today is below.. it's just too darn slow on large log files that it's not worth using.
Code: Select all
// Start at the beginning of the file
UltraEdit.activeDocument.top();
// Search string variable used for deletion of lines
var delString = "text to search for"
// Establish our search string for the loop condition
UltraEdit.activeDocument.findReplace.find(delString);
// Variable to count found items
i = 0;
// Start with nothing on the clipboard
UltraEdit.clearClipboard();
// Loop through the file, count and delete found lines
while (UltraEdit.activeDocument.isFound())
{
// We use an if statement here, because when the above "isFound" is evaluated,
// the script will use the last Find operation for re-evaluation instead of initiating
// a new one, causing one extra unintended deletion.
if (UltraEdit.activeDocument.isFound()) {
UltraEdit.activeDocument.selectLine();
UltraEdit.activeDocument.copyAppend();
i++;
}
UltraEdit.activeDocument.findReplace.find(delString);
}
if (i == 0){
UltraEdit.messageBox("No occurrences of \"" + delString + "\" found in this file.");
} else {
// Create a new file for the report
UltraEdit.newFile();
UltraEdit.activeDocument.paste();
UltraEdit.activeDocument.top();
UltraEdit.activeDocument.write(i + " lines containing \"" + delString + "\" were found in this file.\r\n\r\n");
}
- find results - clipboard
- find dialog