EmEditor 宏以将大文件保存为从 0 到 100,000。

huangapple go评论70阅读模式
英文:

EmEditor Macro to Save Large Files from 0 to 100000

问题

尝试为EmEditor设置一个宏来执行以下步骤,否则我可以手动完成。

  1. 打开文件
  2. 视图 > 大文件控制器
  3. 设置 To=1000
  4. 点击应用
  5. 点击另存为已打开部分...
  6. 输入 TestMacro 并保存

我正在使用:EmEditor 专业版(64 位)版本 22.4.1。Windows 10 操作系统。

我尝试过录制,但似乎不起作用。

然后我尝试了此代码片段的变体,但提供的错误是指定的文件不存在。

editor.WriteProfileInt( eeRegCommon, "", "DefaultBytesTo", 1000 );    // 打开到 1000 字节
editor.RefreshCommonSettings();
editor.OpenFile( "D:\\Test\\Input.txt", 0, eeOpenDetectUnicode | eeOpenDetectUTF8 );
editor.WriteProfileInt( eeRegCommon, "", "DefaultBytesTo", 0 );       // 打开到无限制
editor.RefreshCommonSettings();
editor.ExecuteCommandByID(4323);  // 清除此文档中的所有书签
editor.ExecuteCommandByID(4588);  // 反转此文档中的所有书签
editor.ExecuteCommandByID(4590);  // 提取此文档中的所有书签行到新文件
document.Save( "D:\\Test\\TestMacro.txt" );

如何设置这个宏以实现这些步骤?

将文件路径编辑为 "input" 而不是 "input.txt" 后,错误得到了解决。

英文:

Trying to set up a macro for EmEditor to execute the following steps that I could otherwise do manually.

  1. open file
  2. view > large file controller
  3. set To=1000
  4. Click Apply
  5. Click Save Opened Portion As...
  6. Enter TestMacro and Save

I'm using: EmEditor Professional (64-bit) version 22.4.1. Windows 10 operating system.

I tried recording, that didnt seem to work.

Then I tried variations of this snippet suggested as answer but error provided was specificed file does not exist.

editor.WriteProfileInt( eeRegCommon, "", "DefaultBytesTo", 1000 );    // open to 1000 bytes
editor.RefreshCommonSettings();
editor.OpenFile( "D:\\Test\\Input.txt", 0, eeOpenDetectUnicode | eeOpenDetectUTF8 );
editor.WriteProfileInt( eeRegCommon, "", "DefaultBytesTo", 0 );       // open to unlimited
editor.RefreshCommonSettings();
editor.ExecuteCommandByID(4323);  // Clear All Bookmarks in This Document
editor.ExecuteCommandByID(4588);  // Invert Bookmarks in This Document
editor.ExecuteCommandByID(4590);  // Extract Bookmarked Lines in This Document to New File
document.Save( "D:\\Test\\TestMacro.txt" );

How is this macro set up to achieve these steps?

After editing my file path to "input" instead of "input.txt" error was resolved.

EmEditor 宏以将大文件保存为从 0 到 100,000。

答案1

得分: 1

我编写了一个宏来打开文件 E:\Test\Input.txt 到 1000 字节,并将其保存为 E:\Test\TestMacro.txt

注意:

  • 你也可以在“自定义”对话框的“文件”页面更改默认的 To 字节,但这个宏只会在打开文件时更改它,并在完成后自动恢复为默认值。
  • 没有宏方法等同于“另存已打开部分为”,但你可以为所有行设置书签,提取带书签的行到一个新文件,然后将新文件保存为 TestMacro.txt
editor.WriteProfileInt( eeRegCommon, "", "DefaultBytesTo", 1000 );    // 打开为 1000 字节
editor.RefreshCommonSettings();
editor.OpenFile( "E:\\Test\\Input.txt", 0, eeOpenDetectUnicode | eeOpenDetectUTF8 );
editor.WriteProfileInt( eeRegCommon, "", "DefaultBytesTo", 0 );       // 打开为无限制
editor.RefreshCommonSettings();
editor.ExecuteCommandByID(4323);  // 清除此文档中的所有书签
editor.ExecuteCommandByID(4588);  // 反转此文档中的书签
editor.ExecuteCommandByID(4590);  // 将此文档中的带书签行提取到新文件
document.Save( "E:\\Test\\TestMacro.txt" );
英文:

I wrote a macro to open a file E:\Test\Input.txt to 1000 bytes, and save it as E:\Test\TestMacro.txt.

Notes:

  • You can also change the default To bytes in the File page of the Customize dialog box, but this macro will change this only while opening the file, and revert it to default automatically when done.
  • There is no macro method equivalent to Save Opened Portion As, but you can set bookmarks to all lines, extract bookmarked lines to a new file, and then save the new file as TestMacro.txt.
editor.WriteProfileInt( eeRegCommon, "", "DefaultBytesTo", 1000 );    // open to 1000 bytes
editor.RefreshCommonSettings();
editor.OpenFile( "E:\\Test\\Input.txt", 0, eeOpenDetectUnicode | eeOpenDetectUTF8 );
editor.WriteProfileInt( eeRegCommon, "", "DefaultBytesTo", 0 );       // open to unlimited
editor.RefreshCommonSettings();
editor.ExecuteCommandByID(4323);  // Clear All Bookmarks in This Document
editor.ExecuteCommandByID(4588);  // Invert Bookmarks in This Document
editor.ExecuteCommandByID(4590);  // Extract Bookmarked Lines in This Document to New File
document.Save( "E:\\Test\\TestMacro.txt" );

huangapple
  • 本文由 发表于 2023年5月29日 05:16:32
  • 转载请务必保留本文链接:https://go.coder-hub.com/76353632.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定