Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #10487

    Stefan
    Participant

    I just had again the need to put to directory listings
    together side by side for to use with e.g. renamer BRU.

    Something like:

    LEFT:
    D:Pathfile01.ext
    D:Pathfile02.ext
    D:Pathfile03.ext
    RIGHT:
    D:Pathnew name01.ion
    D:Pathnew name02.ion
    D:Pathnew name03.ion
    BECOMES joined (for “Renaming From A Text File” for BRU):
    D:Pathfile01.ext|D:Pathnew name01.ion
    D:Pathfile02.ext|D:Pathnew name02.ion
    D:Pathfile03.ext|D:Pathnew name03.ion

    Therefor i wrote an script i wanted to for longer.

    How to use:
    – Open an new document.
    – Paste the first list in.
    – Add underneath an empty line and write 5 #’s
    – Paste the second list beneath.

    – BE SURE to have no empty lines!
    – And best have same amount of lines in both list.

    – Change Separator and Delimiter in script if needed.

    – Execute this macro, the joined output
    will be pasted into an new document.

    Example use:

    INPUT document (##### as separator):
    D:Pathfile01.ext
    D:Pathfile02.ext
    D:Pathfile03.ext
    ##### < remember: at least 5 #'s
    D:Pathnew name01.ion
    D:Pathnew name02.ion
    D:Pathnew name03.ion

    OUTPUT document (Pipe | as delimiter):
    D:Pathfile01.ext|D:Pathnew name01.ion
    D:Pathfile02.ext|D:Pathnew name02.ion
    D:Pathfile03.ext|D:Pathnew name03.ion

    Here is the script:


    //EmEditor Script (JavaScript)
    // Paste/Merge/Join two list together side-by-side.
    // (see examples) Writes result to new document.
    //
    // Works like one feature of PASTE.exe
    // paste is a Unix command line utility which
    // is used to join files horizontally (parallel merging)
    // by outputting lines consisting of the sequentially
    // corresponding lines of each file specified, [...]
    // It is effectively the horizontal equivalent to the
    // utility cat command which operates on the vertical
    // plane of two or more files.
    //=======================================================

    // How to use:
    // - Open an new document.
    // - Paste the first list in.
    // - Add underneath an empty line and write 5 #'s
    // - Paste the second list beneath.
    // -
    // - BE SURE to have no empty lines!
    // - And best have same amount of lines in both list.
    // -
    // - Change Separator and Delimiter in script if needed.
    // -
    // - Execute this macro, the joined output
    // will be pasted into an new document.


    //=======================================================
    //============ U S E R S E T T I N G S ==================

    // Separate your two input list by at least 5 #'s
    // Example input:
    // Eins
    // Zwei <<< Left side in output
    // Drei
    // Vier
    // ##### <<< Five or more #'s, but not less!
    // One
    // Two
    // Three <<< Right side in output
    // Four
    //
    Separator = "#####";

    // Delimiter to be used for separating
    // consecutive values on a single line.
    // Join both input lists side-by-side,
    // separated by that sign in the output
    // Example output:
    // Eins|One
    // Zwei|Two
    // Drei|Three
    // Vier|Four
    //
    Delimeter = "|";



    //===========================================================
    //===========================================================
    //============ T H E S C R I P T ==========================

    document.selection.SelectAll();
    sel = document.selection.Text; //alert(sel);
    Lines = sel.split("rn"); //Using Windows Line Enders here
    SeparatorFound = false;
    aArr = new Array();
    nCount=0;

    for(L = 0, Ls = Lines.length; L < Ls; L++){
    if (Lines[L].indexOf(Separator) != -1){
    SeparatorFound = true; continue; //SKIP
    }
    if (SeparatorFound==false){
    aArr[L] = Lines[L]; nCount++;
    }else{
    aArr[L -nCount -1] += Delimeter + Lines[L];
    }
    }

    //============ O U T P U T =================================
    OUT = aArr.join("rn");
    //alert(OUT);

    //Works with EmEditor:
    editor.NewFile();
    document.write(OUT);

    //The End
    //===========================================================
    #10488

    Stefan
    Participant

    Merge two list together side-by-side RANDOM-ized

    Hi folks, I was asked how to
    random the two list together side-by-side.

    Here is my answer:


    //EmEditor Script (JavaScript)
    // Merge two list together side-by-side RANDOM-ized
    // shuffle intermix stochastic stochastically
    // (see examples) Writes result to new document.

    //=======================================================
    //============ U S E R S E T T I N G S ==================

    // Separate your two input list by at least 5 #'s
    // Example input:
    // JAMES
    // JOHN <<< Left side in output
    // WILLIAM
    // RICHARD
    // CHARLES
    // ########## <<< Five or more #'s, but not less!
    // MARY
    // PATRICIA
    // LINDA <<< Right side in output
    // BARBARA
    // ELIZABETH
    Separator = "#####";



    // Delimiter to be used for separating
    // consecutive values on a single line.
    // Join both input lists side-by-side,
    // separated by that sign in the output
    // Example output:
    // WILLIAM + ELIZABETH
    // CHARLES + PATRICIA
    // RICHARD + BARBARA
    // JAMES + MARY
    // JOHN + LINDA
    // or
    // JOHN + BARBARA
    // JAMES + PATRICIA
    // RICHARD + ELIZABETH
    // CHARLES + LINDA
    // WILLIAM + MARY
    // or
    // WILLIAM + PATRICIA
    // JAMES + BARBARA
    // RICHARD + ELIZABETH
    // CHARLES + LINDA
    // JOHN + MARY
    // or...
    //
    Delimeter = " + ";



    //===========================================================
    //===========================================================
    //============ T H E S C R I P T ==========================

    document.selection.SelectAll();
    sel = document.selection.Text; //alert(sel);
    Lines = sel.split("rn"); //Using Windows Line Enders here
    SeparatorFound = false;
    arrONE = new Array();
    arrTWO = new Array();
    arrOUT = new Array();

    for(L = 0, Ls = Lines.length; L < Ls; L++){
    if (Lines[L].indexOf(Separator) != -1){
    SeparatorFound = true; continue; //SKIP
    }
    if (SeparatorFound==false){
    arrONE[L] = Lines[L];
    }else{
    arrTWO[L] = Lines[L];
    }
    }

    //Randomize the order of the array:
    arrONE.sort( function() {return 0.5 - Math.random()} );
    arrTWO.sort( function() {return 0.5 - Math.random()} );
    //Join the arrays side-by-side:
    for(idx=0,Len=arrONE.length; idx<Len; idx++){
    arrOUT[idx] = arrONE[idx] + Delimeter + arrTWO[idx];
    }
    //============ O U T P U T =================================
    OUT = arrOUT.join("rn");
    //alert(OUT);

    //Works with EmEditor:
    editor.NewFile();
    document.write(OUT);

    //The End
    //===========================================================

    shuffle intermix stochastic stochastically random randomized

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

Share with friends... Tweet about this on TwitterShare on FacebookShare on Google+Email this to someone