Mobile app version of vmapp.org
Login or Join
Alves566

: Merge content of files line by line (intersperse lines) 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

@Alves566

Posted in: #AdobeIndesign #Automation #BatchProcessing #IndesignScripting #Workflow

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 and get started.

Any suggestions for a reasonably practical work flow would be appreciated (it does not need to be completely automated). 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.

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Alves566

2 Comments

Sorted by latest first Latest Oldest Best

 

@Yeniel278

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.

10% popularity Vote Up Vote Down


 

@Kimberly620

Yes, its a bit unfortunate that peoples computer literacy skills are in general as low as yours is. But that is normal I suppose. I would do it with my text editor or sed but that's just me. The answer put forth is quite straightforward. But lets do this in inDesign.


Start inDesign and open a new document (and nothing else)
Import


contents of FILE 1 into one text frame
contents of FILE 2 contents into another text frame

Start ExtendScript Toolkit (if you have any adobe software installed then it gets installed).


Choose File -> New JavaScript
paste following into the document:
#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--){
text1.paragraphs[p].contents += text2.paragraphs[p].contents;
}

Hit the arrow labeled "start running..." to execute



That is about all there is for merging the lines. You can easily go much further but that's another thing entirely. Yes there is really no need to have a single human in a publishing pipeline, today.

Things to watch out for there ABSOLUTELY has to be a 1:1 correspondence between lines or this will fail. Also do not use this script in any other environment except a new document with just 2 frames.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme