英文:
EmEditor Macro to Save Large Files from 0 to 100000
问题
尝试为EmEditor设置一个宏来执行以下步骤,否则我可以手动完成。
- 打开文件
- 视图 > 大文件控制器
- 设置 To=1000
- 点击应用
- 点击另存为已打开部分...
- 输入 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.
- open file
- view > large file controller
- set To=1000
- Click Apply
- Click Save Opened Portion As...
- 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.
答案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 theFile
page of theCustomize
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 asTestMacro.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" );
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论