11 Replies Latest reply on Jan 5, 2012 7:52 AM by John Hawkinson

    Merging different text files

    HetBruist

      I am making a year book for wich I have many Word files and pictures. I think the data merge should be a perfect way to bring all these different texts and photo's into my lay out. But the text i can not get it to work. I can get the pictures to work but somehow i cannot load the different text files into the lay out? Can anyone tell if this is possible and how? thnx a lot (PS I am working with CS4)

        • 1. Re: Merging different text files
          Grant H Level 4

          Place the text doc.

           

          G

          • 2. Re: Merging different text files
            HetBruist Level 1

            That would mean that I need to place 430 text files (for the 430 people), isn't it? Isn't there a way to load or link them just the way you do with pictures?

            • 3. Re: Merging different text files
              John Hawkinson Level 5

              I think the data merge should be a perfect way to bring all these different texts and photo's into my lay out. But the text i can not get it to work. I can get the pictures to work but somehow i cannot load the different text files into the lay out? Can anyone tell if this is possible and how?

              Data Merge cannot place text files.

              There is no out-of-the-box way to accomplish what you want.

               

              One answer might be to merge the filenames into the text boxes, leaving you with 100 (or whatever, err 432) text boxes each with a filename in it. Then, run a script to look at each text box, and if its sole contents is a filename, place that file into the box. It's probably a 5-line script.

              1 person found this helpful
              • 4. Re: Merging different text files
                Peter Spier Most Valuable Participant (Moderator)

                You can certainly select multiple files and fill the place gun with them, but there's no way use data merge to place individual text files. You'd need to make a single text file with the text in one field and the path to your image in another, then have one record like that for each of your people.

                1 person found this helpful
                • 5. Re: Merging different text files
                  HetBruist Level 1

                  Thank you Peter and John. I will try johns way first to see if i can get the script to work!

                  The text is about a 200 words for each person, so to put that in the excel file will be very messy I am afraid.

                  • 6. Re: Merging different text files
                    Grant H Level 4

                    Here is one from

                    Peter Kahrel

                     

                     

                    // Description: Place multiple textfiles as one story

                     

                    #target indesign

                     

                    preset = '/d/test/*.rtf';

                     

                    app.wordRTFImportPreferences.useTypographersQuotes = true;

                    app.wordRTFImportPreferences.convertPageBreaks = ConvertPageBreaks.none;

                    app.wordRTFImportPreferences.importEndnotes = true;

                    app.wordRTFImportPreferences.importFootnotes = true;

                    app.wordRTFImportPreferences.importIndex = true;

                    app.wordRTFImportPreferences.importTOC = false;

                    app.wordRTFImportPreferences.importUnusedStyles = false;

                     

                     

                    mask = prompt ('Enter a file path/mask.\r\r' +

                        'Examples:\r' +

                        'd:\\books\\test\\*.rtf   /d/books/test/*.rtf', preset);

                     

                    if (mask == null) exit();  // Cancel pressed

                     

                    ff = Folder (File (mask).path).getFiles (File (mask).name);

                    if (ff.length > 0)

                        {

                        placed = [];

                        missed = [];

                        tframe = app.documents.add().textFrames.add({geometricBounds : [36, 36, 400, 400]});

                        placedstory = tframe.parentStory;

                        app.scriptPreferences.userInteractionLevel =

                            UserInteractionLevels.neverInteract;

                        pb = initprogressbar (ff.length, 'Loading');

                        for (i = 0; i < ff.length; i++)

                            {

                            pb.value = i;

                            try

                                {

                                placedstory.insertionPoints[-1].place (ff[i]);

                                placedstory.insertionPoints[-1].contents = '\r\r';

                                placed.push (ff[i].name);

                                }

                            catch (_)

                                {

                                missed.push( ff[i].name );

                                }

                            }

                        app.scriptPreferences.userInteractionLevel =

                            UserInteractionLevels.interactWithAll;

                        inform = '';

                        if (placed.length > 0)

                            inform = 'Placed ' + ff.length + ' files (in this order):\r\r' + placed.join ('\r');

                        if (missed.length > 0)

                            inform += '\r\rCould not place:\r\r' + missed.join ('\r');

                        delete_empty_frames ();

                        alert( inform );

                        }

                    else

                        alert (mask + ' not found.');

                     

                    // End

                     

                     

                    function delete_empty_frames ()

                        {

                        app.findGrepPreferences = app.changeGrepPreferences = null;

                        app.findGrepPreferences.findWhat = '\\A\\Z';

                        var empties = app.activeDocument.findGrep (true);

                        for (var i = 0; i < empties.length; i++)

                            empties[i].parentTextFrames[0].remove()

                        }

                     

                     

                    function initprogressbar (stop, title)

                        {

                        progresswindow = new Window('palette', title);

                        progressbar = progresswindow.add ('progressbar', undefined, 1, stop);

                        progressbar.preferredSize = [200,20];

                        progresswindow.show ()

                        return progressbar;

                        }

                    • 7. Re: Merging different text files
                      Jeffrey_Smith Most Valuable Participant

                      Unless your document will be one continous threaded story, there would be no benefit to having one text file. From your description of "yearbook", I envision the typical page layout of a photo + text below in a grid of columns and rows, and one text file would have to be broken up anyway.

                      • 8. Re: Merging different text files
                        John Hawkinson Level 5

                        Grant:

                        Here is one from Peter Kahrel

                        // Description: Place multiple textfiles as one story

                        Well, that's a lot more than five lines.

                        But how is that supposed to help? HetBruist needs to place hundreds of stories in hundreds of specific boxes correlated with photos, etc.

                        • 9. Re: Merging different text files
                          Eugene Tyson Adobe Community Professional & MVP

                          I'd use Acrobat Pro to combine all the Word docs into a single pdf. Then I'd export that PDF as RTF.

                           

                          In Acrobat Pro go to File>Combine>Merge Files as Single PDF

                           

                          Once all the files are combined in a single PDF choose File>Export>Text

                           

                           

                          Then you will be able to place all the text as a single story in InDesign.

                          • 10. Re: Merging different text files
                            Eugene Tyson Adobe Community Professional & MVP

                            In fact - I may have out done myself here. Here's a way you can do it in Ms Word!

                             

                            File>New document

                             

                            Insert>File

                             

                            Select all the files you want - and it inserts them into a single Word file.

                             

                            Save it - then in InDesign use File>Place

                             

                            or you can copy and paste it all from Word!

                            • 11. Re: Merging different text files
                              John Hawkinson Level 5

                              Eugene:

                              Then you will be able to place all the text as a single story in InDesign.

                              That's not the goal!!  (That is also what Grant's Peter Kahrel script accomplishes). Though maybe I'm confused about the goal...

                               

                              HetBruist is making a yearbook, with fixed size text areas that correlate with picture elements and possibly other text frames. He doesn't want to have a single story.

                               

                              (I suppose he could produce 432 linked text frames and have frame breaks between each story. I don't think this is a great way to do such a layout, and I'm not sure how that interacts with datamerging the photos, but I guess it is an option... Seems like a bad one to me, though. )