4 Replies Latest reply on Mar 15, 2011 11:07 PM by Danny Noonan

    [CS4]Export Labeled Text Box's Content to .txt Document

    Danny Noonan Level 1

      Hello

      I have hundreds of documents, 99% of these documents have labeled text boxes. I would like to get the contents of these text boxes(stories?) and export to a text file.

      If anyone could assist me do the following, I would greatly appreciate it.

       

      1)Look for any text box in the already open document with the script label starting with the word "imagenote". The script label always starts with "imagenote" and ends with a dash "-" followed by 1 to 6 digits. So an example of a full label would be, "imagenote-1234". If there are no text boxes with the script label, do nothing.

       

      2)If a the label is found, export a text document. The text document should have the same name as the InDesign document itself. If there is more than one text box label found, export one for each.

       

      Things to note:

      The labeled text box might be on a hidden layer.

      There will probably be missing fonts. If there are missing fonts, or missing images for that matter, it would be best if InDesign didn't through any warnings.

       

       

      If this is possible, or anyone has something similar to this, please help.

       

      Thank you very much for any assistance with this.

       

      Danny

        • 1. Re: [CS4]Export Labeled Text Box's Content to .txt Document
          John Hawkinson Level 5
          I have hundreds of documents,

          ...

          1)Look for any text box in the already open document

           

          Err, if you have hundreds of documents, why do you want to do this only on the open document? That sounds like a lot of unnecessary manual work.

           

           

           

          1)Look for any text box in the already open document with the script label starting with the word "imagenote". The script label always starts with "imagenote" and ends with a dash "-" followed by 1 to 6 digits. So an example of a full label would be, "imagenote-1234". If there are no text boxes with the script label, do nothing.

          This is really trivial.

          var
              i,
              doc=app.activeDocument,
              texts = doc.textFrames;
          for (i=0; i<texts.length; i++) {
              if (texts[i].label.match(/^imagenote/)) {
                  texts[i].exportFile(ExportFormat.TEXT_TYPE,
                      doc.fullName+".txt");
              }
          }
          

          2)If a the label is found, export a text document. The text document should have the same name as the InDesign document itself. If there is more than one text box label found, export one for each.

          I don't know what you want to happen if there's more than one with the same name. I'll let you figure that out.

          Things to note:

          The labeled text box might be on a hidden layer.

          There will probably be missing fonts. If there are missing fonts, or missing images for that matter, it would be best if InDesign didn't through any warnings.

          Throw? Neither of those should matter if you're exporting a text frame in an already-open document.

          Hidden layers are also not a factor.

          • 2. Re: [CS4]Export Labeled Text Box's Content to .txt Document
            Danny Noonan Level 1

            Hi John Hawkinson,

            I appreciate your assistance.

            Sorry for the delayed response.

             

            This is really trivial.

             

            I tried the script you posted on my Mac, I get the result: "The specified object does not support the desired export format." So, I tried it on my not so cool PC to see if it worked. Same result.

            I was getting the same outcome when I tried set up my own export to text script. What is it missing? Were you able to produce a text document? I can't seem to get results!

            Err, if you have hundreds of documents, why do you want to do this only on the open document? That sounds like a lot of unnecessary manual work.

            99% of these documents are single pagers, occasionally, we'll receive a two pager. I should have noted, none of this is "manual work". We have automation in place which opens one document at a time and runs a script to collect images from our DAM. All I wanted was to tag this onto what was already happening. Ultimatlely, we don't get all of these documents at "once". We could potentially get hundreds of InDesign documents in a week, but not at the same time. For example,we might receive one document and an hour later, we could get 30 documents. We need to get these into production asap. We would like to get the text document produced within minutes of receiving the document. This is the most efficiant way for us to service the customer.

             

             

            Things to note:

            The labeled text box might be on a hidden layer.

            There will probably be missing fonts. If there are missing fonts, or missing images for that matter, it would be best if InDesign didn't through any warnings.

            Throw? Neither of those should matter if you're exporting a text frame in an already-open document.

            Hidden layers are also not a factor.

             

            Throw? Yes! Not "through"! Thank you. I hate it when I do this Sh...

            I noticed hidden layers were not a factor when I modified the Adobe supplied "ExportToText"(?) I am not sure exactly what the scipt is called but it worked as supplied, hidden layers were inclued.  I got the same result with the mods I made to the supplied Adobe script as I did with the one you posted. When I was receiving this error, I decided to ask on the forum.

             

            If you can assist me any further, I'd appreciate it. This forum is awesome. I've learned a lot from you pros.

             

            Thanks again,

             

            Danny

            • 3. Re: [CS4]Export Labeled Text Box's Content to .txt Document
              John Hawkinson Level 5

              Sorry about that, Danny. "trivial" is code for, "I'm not going to bother to test this, I'm going to assume it'll work or be close enough to working that you'll figure it out and maybe learn something in the process." Perhaps, "left as an exercise to the reader?"

               

              In this case, there were two errors. First, you must export a story, not a textFrame. Second, you must make a File() out of the filename. And thirdly, perhaps you want "x.txt" not "x.indd.txt". So replace the guts with:

               

                      texts[i].parentStory.exportFile(ExportFormat.TEXT_TYPE,
                          new File(doc.fullName.replace(/\.indd$/,"")+".txt"));
              
              

              All tested except the .replace().

              1 person found this helpful
              • 4. Re: [CS4]Export Labeled Text Box's Content to .txt Document
                Danny Noonan Level 1

                Thanks John

                I will post my final results when I get them. You have been very helpful in my endevour to get a text document.

                I do appreciate your learning excercise! Someday, I'll be able to help some Jabroni like myself.

                 

                Thanks again, I appreciate it....

                 

                 

                Danny