javascriptmacrosemeditor

EmEditor Macro to Save Large Files from 0 to 100000


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.

enter image description here


Solution

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

    Notes:

    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" );