1

是的,我知道“批量替换”,但是

我的替换列表很大,有 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");

emeditor 批量替换

4

1 回答 1

1

我将在未来的版本中优化文件中的批量替换。同时,请尝试使用“搜索组中的所有文档”选项进行(正常)批量替换。您可以这样做:

  1. 将 EmEditor 更新到 v19.2.2(或更高版本)。

  2. 打开 EmEditor,选择工具菜单 -自定义-选项卡页面,然后从When Not Fit下拉列表中选择None ,然后从Width下拉列表中选择Fix to specified with 。

  3. 使用 EmEditor 打开所有(或部分)文件。一个简单的方法是将多个文件从 Windows 资源管理器拖放到 EmEditor。

  4. 在 EmEditor 中,按Ctrl + H显示替换对话框,单击批处理 >>,设置搜索组中所有打开的文档,确保批处理列表已更新,然后单击全部替换按钮。

(正常)批量替换将按预期工作(在 file1 中使用 item1....item200,在 file2 中使用 item1...item200 等)。

于 2020-06-21T04:57:37.683 回答