Copy link to clipboard
Copied
Hello,
I am using Windows 10 and InDesign CS6. I would like to take 2 files, mix the content line by line and output to a third file to make an ebook, as follows.
INPUT FILE 1 (e.g. TXT, XML, SQL, etc.)
[This file is already in a line by line format -- each line is demarcated by a return.]
line 1
line 2
line 3
etc.
INPUT FILE 2 (INDD)
[This file is in the form of flowing text and each line will have to be demarcated e.g. 1 line = every text string that starts with capital letter and ends with "full stop + space".]
line A [footnote 1]
line B [footnote 2]
line C [footnote 3]
etc.
OUTPUT FILE 3 (e.g. EPUB, HTML, XML, etc.)
line 1
line A [footnote 1]
line 2
line B [footnote 2]
line 3
line C [footnote 3]
etc.
I found some relevant discussions here and here (the gist is that *nix systems have a paste function, Excel has a concertina function, and a method in the DOS command prompt and some other scripting methods were suggested). I am afraid these discussions are a bit cryptic for me and do not help my situation completely. I am computer literate but do not have coding experience so am looking for some help here to show me the way.
Any suggestions for a good work flow would be appreciated. I'd also like to explore if Input File 1 was, say, a DOC or an INDD file of flowing, undemarcated text. It would be nice to have some flexibility in the workflow.
Kasyan Servetsky kindly suggested that I use the move method and here is the result which appears to work fine...
#target indesign
var doc = app.activeDocument;
var text1 = doc.pages[0].textFrames[1].parentStory;
var text2 = doc.pages[0].textFrames[0].parentStory;
for(var p = text2.paragraphs.length-1; p >= 0 ; p--){
text2.paragraphs[p].move(LocationOptions.AFTER, text1.paragraphs[p]);
}
So, the answer to the original question is to prepare the text of INPUT FILE 1 and INPUT FILE 2 within InDesign (two
...Copy link to clipboard
Copied
Kasyan Servetsky kindly suggested that I use the move method and here is the result which appears to work fine...
#target indesign
var doc = app.activeDocument;
var text1 = doc.pages[0].textFrames[1].parentStory;
var text2 = doc.pages[0].textFrames[0].parentStory;
for(var p = text2.paragraphs.length-1; p >= 0 ; p--){
text2.paragraphs[p].move(LocationOptions.AFTER, text1.paragraphs[p]);
}
So, the answer to the original question is to prepare the text of INPUT FILE 1 and INPUT FILE 2 within InDesign (two separate text frames on one page) and then run the above script.
To see how this solution developed see: adobe indesign - Merge content of files line by line (intersperse lines) - Graphic Design Stack Exch...