是的,我知道“批量替换”,但是
我的替换列表很大,有 200 多个项目,我将在一个有很多文件的大文件夹中使用它。
现在,emediter 的行为是在所有文件中使用 item1,然后在所有文件中使用 item2 .....
预期:在 file1 中使用 item1....item200,在 file2 中使用 item1...item200
怎么做 ?
我尝试使用宏(openfile、replace、closefile),但速度很慢,因为打开一个文件需要 50 毫秒
编辑器 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");