Hi DiamondEagle
If you searched forum for "batch" you will see several discussions of invoking UE in command line mode and specifying a file list to open and macro to invoke - see for instance:
Search & replace macro from a list of file names
But I have used another approach several times - but it is only possible for UE13 !
Under "Advanced / tool configuration" I have made a tool called "DIR" with performs a simple DIR dos command :
Code: Select all
DIR /A-D-H-S /B /S C:\temp\work\*.xml %modify%
(see DIR /? for explanation)
Tool options: Create new file, capture output, %modify% = popup box with command line
The macro I want to use on multiple files is assigned in "Macro" "Set macro for file load/save". I use "..on load" 1 times.
You might want to guard against this macro being invoked on unwanted files - for example use a test with IfExtIs (tests extension)
Code: Select all
InsertMode
ColumnModeOff
HexOff
UnixReOff
IfExtIs "xml"
"DO STUFF"
EndIf
To process multiple files with the macro of choice, I then use this script:
Code: Select all
//batchInvokeMacro.js
//Configure a tool called "DIR" that performs a DOS DIR command (see in findDirFiles)
var CRLF = "\r\n";
dirFiles = new Array();
findDirFiles();
if (dirFiles.length>0)
performBatchProcessing();
///////////////////////////////////////////////////////////////////////////////////////////////////
// Call tool "DIR" which make
// dir /A-D-H-S /B /S root-filepath/filemask
// (no dirs, no hidden, no system, short list, subdirectories)
// root-filepath/filemask of your choice (eg. c:\temp\*.txt)
// tool should capture DOS output to new file
function findDirFiles() {
UltraEdit.runTool("DIR");
dirDoc = UltraEdit.document[getActiveDocumentIndex()];
dirDoc.selectAll();
var dirOutput = dirDoc.selection;
dirFiles = dirOutput.split(CRLF);
UltraEdit.closeFile(dirDoc.path,2);
}
/* loop through files and do processing of your choice */
function performBatchProcessing() {
for (i=0;i<dirFiles.length;i++) {
if (dirFiles[i].length>0) {
UltraEdit.open(dirFiles[i]); /* Open file, load macro "fires" */
UltraEdit.closeFile(dirFiles[i],1); /* save and close */
}
}
}
/* Find the tab index of the active document */
function getActiveDocumentIndex() {
var tabindex = -1; /* start value */
for (i = 0; i < UltraEdit.document.length; i++)
{
if (UltraEdit.activeDocument.path==UltraEdit.document[i].path) {
tabindex = i;
break;
}
}
return tabindex;
}
Remember to remove your "..on load" macro option if this was a one time job.
Now adjust the above to your situation and then go get a cut of coffee while the script works its way through a 1000 files. I hope you found some inspiration in this.
Cheers, jorrasdk