Reputation: 352
yes,I know "Batch Replace All",but
my replace list is so big,has 200+ items, i will use it in a big folder which has a lot of files.
now,emediter's behave is that use item1 in all files,then use item2 in all files.....
expected: use item1....item200 in file1,and use item1...item200 in file2
how to do it ?
I attempt use the macros(openfile,replace,closefile),but it is very slowly because open a file need 50ms
emeditor 19.9.1
var fso = new ActiveXObject("Scripting.FileSystemObject");
var files = [];
var filesHasModified = [];
function showFolderFileList(folderspec) {
var f = fso.GetFolder(folderspec);
if(/\\(doc|lib|\.git|\.idea|\.vs|dll)$/gi.test(folderspec)){
return;
}
// recurse subfolders
var subfolders = new Enumerator(f.SubFolders);
for(; !subfolders.atEnd(); subfolders.moveNext()) {
showFolderFileList((subfolders.item()).path);
}
// display all file path names.
var fc = new Enumerator(f.files);
for (; !fc.atEnd(); fc.moveNext()) {
var file = fc.item();
if(/\.(jmx|config|cs|Config|tt|ttinclude|txt|yml|java|bak|xml|cshtml|sh|yaml|js|json|md|properties)$/gi.test(file)){
files.push(file);
}
}
}
showFolderFileList('D:\\Sources.git2');
for( i in files)
{
var file = files[i];
editor.OpenFile(file);
document.selection.Replace("http://172xx","http://offline.esb.xx",eeReplaceAll,0);
document.selection.Replace("http://172xx1","http://offline.esb.xx",eeReplaceAll,0);
document.selection.Replace("http://172xx2","http://offline.esb.xx",eeReplaceAll,0);
//....200 more
if(document.Saved)
{
document.close();
}
else
{
filesHasModified.push(file);
document.Save(file);
document.close();
}
}
editor.NewFile();
document.selection.Text = filesHasModified.join("\r\n");
Upvotes: 1
Views: 745
Reputation: 1806
I will optimize Batch Replace in Files in a future version. Meanwhile, please try (normal) Batch Replace with the Search All Documents in the Group option. This is how you can do:
Update EmEditor to v19.2.2 (or later).
Open EmEditor, select Tools menu - Customize - Tab page, and select None from the When Not Fit drop-down list, and select Fix to specified with from the Width drop-down list.
Open all (or some) files with EmEditor. An easy way is to drag and drop multiple files from Windows Explorer into EmEditor.
In EmEditor, press Ctrl + H
to show Replace dialog box, click Batch >>, set the Search All Open Documents in the Group, make sure the batch list is updated, and click the Batch Replace All button.
The (normal) Batch Replace will work as you expect (use item1....item200 in file1, and use item1...item200 in file2, etc.).
Upvotes: 1