6 Replies Latest reply on Apr 28, 2013 11:54 PM by RinaPatch

    Script to automatically enter document metadata

    RinaPatch

      I need to enter document info as metadata into all of my Indesign documents as they are posted on the web as pdf docs so I wanted a script that would automaticaly enter the data once the document has been saved. I only need 3 fields to be filled.

       

      My document is saved as "1234.1234 Document Name_D1" and the 3 fields I need are:

      Document Title: only the wording after the code and before the underscore "Document Name"

      Author: Is always "Company Name"

      Keywords: only the "1234.1234" before the doc name

       

      I'm not sure if this is at all possible so if it can be done automatically using only the whole document name then I'll take that instead.

       

      Thanks,

        • 1. Re: Script to automatically enter document metadata
          csm_phil Level 4

          Dear RinaPatch,

           

          Can you please try the below JS code? May be it will help to you.

           

           

          var myDocument = app.activeDocument;
          with (myDocument.metadataPreferences){
              author = "Adobe";
              copyrightInfoURL = "http://www.adobe.com";
              copyrightNotice = "This document is copyrighted.";
              copyrightStatus = CopyrightStatus.yes;
              description = "Example of xmp metadata scripting in InDesign CS";
              documentTitle = "XMP Example";
              jobName = "XMP_Example_2003";
              keywords = ["animal", "mineral", "vegetable"];
              var myNewContainer = createContainerItem("http://ns.adobe.com/xap/1.0/", "email");
              setProperty("http://ns.adobe.com/xap/1.0/", "email/*[1]", "someone@adobe.com");
              }
          

           

           

          Otherwise, please provide the details clearly.

           

          thx,

          csm_phil

          • 2. Re: Script to automatically enter document metadata
            RinaPatch Level 1

            Thanks for the above.

             

            What I need though is for the document name to be automatically entered into the documentTitle field once it has been saved. The only info that is always the same is the Author. Does that make sense?

            • 3. Re: Script to automatically enter document metadata
              csm_phil Level 4

              Hi RinaPatch,

               

              I just modified the js code. You just insert this line

               

               

              documentTitle = myDocument.name.split(".indd")[0];
              
              
              

               

              thx,

              csm_phil

              • 4. Re: Script to automatically enter document metadata
                RinaPatch Level 1

                Thanks, that seems to be working.

                 

                This is what I have:

                var myDocument = app.activeDocument;

                with (myDocument.metadataPreferences){

                        author = "Department of Human Services";

                        documentTitle = myDocument.name.split(".indd")[0];

                        }

                 

                Is there any way that the script can be run automatically without going to the script panel, so once the document has been saved?

                 

                Also, is it possible to split the name of the document title into 2 different fields. So for example I save my document as:

                "1234.1234 Document Name_D1"

                 

                I want the documentTitle to be "Document Name" (this is variable depending on what I save the doc as) and the keywords field to be the first part of the name so "1234.1234" - this is the product code which also appears on the actual document itself.

                 

                Thanks again

                • 5. Re: Script to automatically enter document metadata
                  csm_phil Level 4

                  Hi RinaPatch,

                   

                  I have totally modifed the js code as per your above request. I sent the private message to you. Which version of InDesign your are using.

                   

                  thx,

                  csm_phil