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:\Path\file01.ext
D:\Path\file02.ext
D:\Path\file03.ext
RIGHT:
D:\Path\new name01.ion
D:\Path\new name02.ion
D:\Path\new name03.ion
BECOMES joined (for "Renaming From A Text File" for BRU):
D:\Path\file01.ext|D:\Path\new name01.ion
D:\Path\file02.ext|D:\Path\new name02.ion
D:\Path\file03.ext|D:\Path\new 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:\Path\file01.ext
D:\Path\file02.ext
D:\Path\file03.ext
##### < remember: at least 5 #'s
D:\Path\new name01.ion
D:\Path\new name02.ion
D:\Path\new name03.ion
OUTPUT document (Pipe | as delimiter):
D:\Path\file01.ext|D:\Path\new name01.ion
D:\Path\file02.ext|D:\Path\new name02.ion
D:\Path\file03.ext|D:\Path\new 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("\r\n"); //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("\r\n");
//alert(OUT);
//Works with EmEditor:
editor.NewFile();
document.write(OUT);
//The End
//===========================================================