Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #4017
    nocam
    Member

    Is it possible to break down a 306 MB (321,020,147 bytes) file into smaller files that would not exceed 20,000.000 bytes each. The file could be larger for I can zip it but each zip must then not exceed not exceed 20,000.000 bytes each. I am trying to upload a large file to a website.

    I have tried to copy and paste large segments to Notepad but there is a timeout so the paste fails,

    Thanks

    #4018
    Yutaka Emura
    Keymaster

    Before I can write a macro for you, does the split between two files need to be at a new line (between paragraphs), between words, or anywhere?

    #4019
    nocam
    Member

    I would say it needs to be between a new line. Below is a sample of text file lines. This is from a Google Earth kml file that has been converted to text using your program.

    Thanks for responding

    root://icons/palette-3.png
    64
    96
    32
    32

    normal
    #5540:4 (site) (normal)1

    highlight
    #5540:4 (site) (highlight)2

    #4021
    Yutaka Emura
    Keymaster

    Here is JavaScript macro to split the currently active file by the same number of lines, in this case, 1000 lines. You can change it to any number of lines. The result files will be saved as “1.txt”, “2.txt”, “3.txt”, … in this folder. As you see in the comment, you might need to set the root folder, in this case C:Test, and this folder must already exist. I hope this helps!


    if( !editor.EnableTab ){
    editor.EnableTab = true;
    alert( "Please run this macro again." );
    Quit();
    }

    sPath = "C:Test"; // Set the root folder where you want to save the split files. It must already exist.
    // The result files will be save as "1.txt", "2.txt", "3.txt", ... in this folder.
    // If the same file names already exist, these files will be overwritten!
    i = 1;
    Redraw = false;
    while( 1 ) {
    docSearch = editor.ActiveDocument;
    editor.NewFile();
    docResult = editor.ActiveDocument;
    docSearch.Activate();
    docSearch.selection.StartOfDocument();
    docSearch.selection.LineDown( true, 1000 ); // Number of lines for each split file to contain
    sLine = docSearch.selection.Text;
    if( sLine == "" ){
    docResult.Close();
    break;
    }
    docSearch.selection.Delete(1);
    docResult.Activate();
    docResult.selection.Text = sLine;
    docResult.Save( sPath + i + ".txt" );
    i++;
    docResult.Close();
    docSearch.Activate();
    }
    Redraw = true;

    :-)

    #4023
    nocam
    Member

    Yutaka,
    Thank you for taking the time to look at this. I will pass the information on to others also

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.